We're using panelizer to display our nodes and for some reason when we view revisions, the contents displayed via entity_entity_view_content_type_render() is always the live/published version. The node/*/draft revision shows the draft as expected, but node/*/revisions/*/view doesn't. Note, these paths, are provided by the workbench_moderation module.
I've worked around the problem with the attached patch for now, but I suspect it's not best practice. I did try look through the various issue queues for information on this (the issues related to panels and revisions are currently about back end things, not viewing). Thanks.
Comment | File | Size | Author |
---|---|---|---|
#9 | entity_view_ctools_revision-2057751-9.patch | 1.09 KB | Mingsong |
| |||
#8 | revision_support_in-2057751-8.patch | 996 bytes | esolitos |
#3 | entity_view_ctools_revision-2057751-3.patch | 1.02 KB | x610 |
#1 | entity_view_revision-2057751.patch | 829 bytes | alexkb |
Comments
Comment #1
alexkb CreditAttribution: alexkb commentedComment #2
alexkb CreditAttribution: alexkb commentedThis patch is still needed for entity API v1.3, and the same patch applies successfully to the newer version.
Comment #3
x610 CreditAttribution: x610 commentedI confirm that this problem exists, and we have spent a day on figuring out how to make revisions work with page manager before I finally found this topic.
Also, I prefer to use $context instead of using arg(), attached my patch.
Comment #4
alexkb CreditAttribution: alexkb commentedWe're working on a new site, and were having issues with the revisioned content showing even on node/*/draft. I'm not sure what code was involved last time to make this work, but x610's patch solves this, as well as the node/<nid>/revisions/<vid>.
Comment #5
eugene.ilyin CreditAttribution: eugene.ilyin commentedPatch #3 works well for me
Comment #6
paranojik CreditAttribution: paranojik at Cando commentedThis conflicts with #2020325: Entity view CTools plugin doesn't load the correct revision . I'm not sure why another entity_load is even needed here. Shouldn't the context already carry a properly loaded object?
Comment #7
DamienMcKennaThis patch also assumes the entity is a node and references 'nid' and 'vid' without verifying that they exist.
Comment #8
esolitosHei, I encountered this bug myself while working with Workbench Moderation and node revisions.
It is definitely related to #2020325 and in my case this patch is fixing both issues.
Please review my patch and get this committed! :)
Comment #9
MingsongHi esolitos,
Thanks for your work.
Just a minor issue with your patch.
There is an undefined variable error for 'entity_id' on line 128:
$block->content = entity_view($entity_type, array($entity_id => $entity), $conf['view_mode']);
In addition, we'd better check if the $entity variable is set on line 123:
if (!isset($entity) || !$entity) {
Here is the new patch based on your work.
I did a quick test on it and it is working.
Cheers,
Comment #10
jan kellermann CreditAttribution: jan kellermann at werk21 commentedThank you, Mingsong. This patch works for us and solves the problem with workbench_moderation / panels.
We would be pleased to see this patch upstream. Thank you all.
Comment #11
mqannehThanks you Mingsong. This worked for me.
Comment #12
ianwensink CreditAttribution: ianwensink commentedPatch #9 fixes the issue with displaying current revision, instead of draft in combination with Panels. Patch doesn't fix the Edit draft for me.
See: https://www.drupal.org/node/2434729#comment-11833227
Comment #13
fagoFrom reading the code, there seems to be a lot of guessing I cannot make sense of. It might be reasonable, but without comments I've no idea what's going on and I cannot judge. We need properly documented code, that readers can understand without diving into this issue first.
Comment #14
pcambraAgreed that the code could be a bit cleaner, but this is basically using the entity that already comes from $context (auto loaded by ctools) and avoids an unnecessary reload using entity_load_single which will produce the wrong entity.
In my case, I have a panelizer that when trying to display old revisions for a node, will always wrongly display the latest one. This patch fixes it.
Comment #15
pcambraIt's worth saying that #2020325: Entity view CTools plugin doesn't load the correct revision fixes the same problem. The patch there also fixes the issue and it's much clearer but the issue title could be better, as it would seem that it's only fixing a draft exclusive issue while it's fixing a much broader issue of loading revisions in ctools context.
Comment #16
pcambraDefinitely a duplicate of #2020325: Entity view CTools plugin doesn't load the correct revision