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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexkb’s picture

alexkb’s picture

Issue summary: View changes

This patch is still needed for entity API v1.3, and the same patch applies successfully to the newer version.

x610’s picture

I 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.

alexkb’s picture

We'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>.

eugene.ilyin’s picture

Status: Active » Reviewed & tested by the community

Patch #3 works well for me

paranojik’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2020325: Entity view CTools plugin doesn't load the correct revision

This 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?

DamienMcKenna’s picture

This patch also assumes the entity is a node and references 'nid' and 'vid' without verifying that they exist.

esolitos’s picture

Status: Needs work » Needs review
FileSize
996 bytes

Hei, 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! :)

Mingsong’s picture

Hi 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,

jan kellermann’s picture

Thank 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.

mqanneh’s picture

Status: Needs review » Reviewed & tested by the community

Thanks you Mingsong. This worked for me.

ianwensink’s picture

Patch #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

fago’s picture

Category: Support request » Feature request
Status: Reviewed & tested by the community » Needs work

From 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.

pcambra’s picture

Agreed 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.

pcambra’s picture

It'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.

pcambra’s picture

Status: Needs work » Closed (duplicate)