For already published content getting revised on our site:

Good news = our users can see their edits by clicking the "Edit draft" tab

Bad news = our users cannot preview what their edits will look like before publishing them by clicking the "View draft" tab

When I viewed all of the different revisions of the page myself, I couldn't see the draft version of the page created by clicking the View link provided. I could only see their revisions by clicking "Edit draft" from the page itself. I noticed from issue report "Edit draft" opens published revision instead of draft revision that they're experiencing almost the opposite issue, so I'm baffled. Has anyone else experienced this? Does anyone have any ideas on how I can troubleshoot this issue? Thanks for any help.

J

Replication Steps

There may be other ways to replicate this issue, but you can easily see it when using the restws module.

  1. Install Drupal 7.38
  2. Install Workbench Moderation and Restws
  3. Apply the patch from #1838640: restws_page_callback() breaks workbench_moderation (required to fix white screen issue unrelated to this issue)
  4. Enable workbench moderation for a content type
  5. Create moderated content as published
  6. Create a draft of that content
  7. Attempt to view the draft, you should see the published revision.

Comments

mnlund’s picture

We are also experiencing the same issue here. We will look further into it and try to find out why.

katannshaw’s picture

Great! Thanks ramsalt. Please let me know if there's any patch testing that I can help out with.

mnlund’s picture

Hi jayhawkfan75. Are you using Panels and Display suite?

katannshaw’s picture

No I'm not using either of those modules. I only use the core edit form for all of my content.

gremy’s picture

I found the bug in the nodedraft.inc file.
The workbench_moderation_nodedraft() function is returning $function($node); instead of $function($current_node);

gremy’s picture

Status: Active » Needs review
StatusFileSize
new397 bytes

This is the patch to fix this problem.

Status: Needs review » Needs work

The last submitted patch, 6: workbench_moderation--fix-view-draft--2447659-6.patch, failed testing.

katannshaw’s picture

Hi gremy,

Thanks for working on the patch. After installing the patch, I tested it out however it didn't solve the issue for me. This is how I reproduced the issue:

Original body value = "The is a page description." (with only one period at the end)

On an existing content page, I:

  • Clicked "Edit current" tab
  • Changed body to "The is a page description..." (with three periods at the end)
  • Saved to Draft state

RESULT:

  • When viewing "View latest" tab:
    body = The is a page description. (no change from original)
  • When viewing "View draft" tab:
    body = The is a page description. (no change from original)
  • When viewing "Edit latest" tab:
    body = The is a page description... (edit page with change)
zoheir.nabavi’s picture

I am assuming we are facing the same problem here. Workflow and everything is setup nicely, however when 'saving a draft', or clicking on 'view draft' gives WSOD (White screen) on:

/node/1126/revisions/1413/view
and
/node/1126/draft

Cheers,

katannshaw’s picture

@znabavi: Not sure if it's related. I don't get a WSOD on my side. Creating and saving a draft works, but when clicking 'view draft', I'm shown the live/published view instead of the draft view. So there's no way for me to see what the draft view looks like before publishing it. I can only see the draft content entered when editing the page.

zoheir.nabavi’s picture

I think WSOD was mainly because of my setup but had to setup development module + rsyslog in order to see the underlying issue was related to: https://www.drupal.org/node/1838640

t14’s picture

I am getting the WSOD.

This happens when you have a published node and a draft version. When you click View draft WSOD appears.

I see this error in my error logs from the core common.inc file
[] operator not supported for strings in includes/common.inc on line 2487

Seems like it is related to the class attribute in a link not being and array.

Any ideas???

UPDATE
Sorry false alarm. This was related to a custom implementation of hook_men_alter not using an array for the link class.

Thanks for a great module.

jasonlttl’s picture

I looked at the patch in #6 and this did not work for me. Then I traced execution.

To me, it looks like we're losing track of the proper revision in workbench_moderation_router_item_page_callback. The correct node/vid is passed into this function, but when we call menu_get_item, $router_item['page_arguments'] is populated with the published version of the node... and so the correct vid is discarded.


function workbench_moderation_router_item_page_callback($node) {
  $router_item = menu_get_item('node/' . $node->nid);
  if ($router_item['include_file']) {
    require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
  }

  // Call whatever function is assigned to the main node path but pass the
  // current node as an argument. This approach allows for the reuse of of Panel
  // definition acting on node/%node.
  return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
  
  // LINE ADDED: Note, using this return sorta works, but some modules, like restws take different arguments and so it's not safe.
  // and I have no idea what other calls might be happening here. 
  return call_user_func_array($router_item['page_callback'], array($node));
}

If I change our version of workbench_moderation_router_item_page_callback to this, it seems to work both with and without restws (which takes over some paths) installed.


function workbench_moderation_router_item_page_callback($node) {
  $router_item = menu_get_item('node/' . $node->nid);
  if ($router_item['include_file']) {
    require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
  }

  // This is a very, very, very bad/hackish workaround.
  if (in_array($router_item['page_callback'], array('node_page_view', 'restws_page_callback'))) {
    if (is_array($router_item['page_arguments'])) {
      $last_index = count($router_item['page_arguments']) - 1;
      $last = $router_item['page_arguments'][$last_index];
      if (property_exists($last, 'nid') && ($last->nid == $node->nid)) {
        $router_item['page_arguments'][$last_index] = $node;
      }
    }
  }

  // Call whatever function is assigned to the main node path but pass the
  // current node as an argument. This approach allows for the reuse of of Panel
  // definition acting on node/%node.
  return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
}
dgtlmoon’s picture

Priority: Normal » Major

Marking as major, sounds like broken functionality at the core use case of the module

dgtlmoon’s picture

Patch of the above from @jasonlttl

Looks like his changes above also incorporate #1838640: restws_page_callback() breaks workbench_moderation ?

This patch makes the issue go away for me however not when panels is installed (even after I uninstall panels theres still some issue)

dgtlmoon’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Category: Support request » Bug report
katannshaw’s picture

@dgtlmoon: Thanks for the patch. I tried it out on my test install and this is unfortunately what happens for me:

  • I make an edit and save it to draft.
  • When I view the draft I cannot see the edited text.
  • When I click on the Moderate tab and then click on Edit Draft link, the edited text is still not there.
  • When I publish that draft, I can then see my edited text.
  • So now I cannot see the edited text when clicking the "edit draft" link via Moderation or viewing the "View Edit" tab on the page, only when it's published to the page.

Has anyone else has this experience?

dgtlmoon’s picture

Are you using panels? if so, try patch from comment #29 and if not, #40 from #1285090: Panels /node/%/edit forms

mallezie’s picture

Status: Needs work » Needs review
StatusFileSize
new685 bytes

I've simplified the patch in #15
I'm not really sure if i could remove all the checks, but this seems to be working for me.
Let the testbot decide further ;-)

I've removed the change from #1838640: restws_page_callback() breaks workbench_moderation, i think it's easier to leave those two issues seperate, to hopefully get a faster fix.

katannshaw’s picture

@dgtlmoon: I am not using Panels.

@mallezie: I'll give this new patch from #19 a try later today. Thanks.

adamps’s picture

Status: Needs review » Needs work

I'm new to this module, just trying to evaluate it for a site, hence scanning the open issues. I don't see this problem on my site with fairly minimal other modules installed. Scanning the comments, Panels may be relevant, and I don't have that on my test site.

Looking at the most recent patch, it seems that the lines being altered relate to calling the existing router function - which could be different depending on other modules and configuration. At a guess, the router function on my site always picks the latest revision so it's fine. However some other function looks at node->vid and it breaks.

So potentially care needs to be taken - the people who have hit this bug will likely test the fix with the particular scenario where there is a bug. My suggestion is

  1. Work out a scenario that causes the bug and update the issue title/description to reflect that. This will be a big help for other readers to know whether the issue is important to them.
  2. Test the fix on a minimal site without the thing that causes the problem to ensure there is no regression.
  3. Ideally get @gremy to test - he had a different patch, hence probably different router function (page manager??). Maybe the latest patch is good for him, or maybe there is more work to solve the problem for all uesrs.

Thanks!

mallezie’s picture

Just to add to @AdamPS's comment.
I'm using this patch and #1838640: restws_page_callback() breaks workbench_moderation on a site in combination with the restws module. I'm not using panels on that site.

katannshaw’s picture

This unrelated issue with the Revisioning module solved my OP issue today: #2499985: Non-admin users can't see new published and revised content even though they have the right permissions. I disabled and uninstalled the Revisioning module, and then everything started working properly for me with the Workbench Moderation module's stages as well. Can anyone else verify this?

Edit: Removing the Revisioning module fixed several related issues however it didn't fix this issue after all. Installing patch #31 solved my issue as noted on comment #31.

jeebsuk’s picture

Just wanted to add that the patch in #19 solved the issues we were having with this scenario so +1 for #19.

samueljmurray’s picture

#19 along with the patch in #23 from #1838640: restws_page_callback() breaks workbench_moderation is fixing these incompatibilities with Restws for me

samuel.mortenson’s picture

Issue summary: View changes
samuel.mortenson’s picture

Status: Needs work » Needs review

Added replication steps per @AdamPS's comment, moving to Needs Review as this has fixed issues for multiple people and can be easily replicated by maintainers.

adamps’s picture

OK, thanks for the diligence

njbarrett’s picture

On patch #19

@@ -34,6 +34,11 @@ function workbench_moderation_router_item_page_callback($node) {
+  $last = $router_item['page_arguments'][$last_index];

the $last variable is never used, what is the purpose of this line?

mallezie’s picture

@njbarret that line could indeed be removed. Nice find.

katannshaw’s picture

@mallezie: Patch #31 solved my issue as noted on my edit of comment #24. Thanks so much! Ready for RTBC?

mallezie’s picture

Tests pass, and you tested it, so you could mark it RTBC I guess.

katannshaw’s picture

Status: Needs review » Reviewed & tested by the community

With several successful tests I'm marking this RTBC. More tests are always helpful though (AdamPS and others?)

rich.yumul’s picture

StatusFileSize
new859 bytes

The above mentioned patches didn't work for me.

Whenever I sent to /node/[nid]/draft, I'd still see the published version and not the draft revision.

When I investigated it, it looks like the menu handler for /node/[nid]/revisions/[revision_id]/view brought up the proper revisions.

What worked for me was to just setup a redirect to that url in workbench_moderation_node_view_draft().

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 35: workbench-moderation-draft-2447659-35.patch, failed testing.

njbarrett’s picture

Status: Needs work » Reviewed & tested by the community

@rich.yumul Your patch does not apply.

Back to RTBC for the working patch #31

tahiticlic’s picture

Hi,

I've the same problem, but I guess it is because I use page manager. Can you confirm that Workbench cannot work along with page manager ? i.e. draft can't be seen if page manager is involved with a variant
As I've gone through the backtrace, somewhere page manager calls handlers giving them nid and not node, this way there's no possibility to show draft...

By the way, I can't figure out what the #31 patch is dealing with : the return function is the same with same arguments, so the added lines are just noise, isn't it ?

Regards,

tahiticlic’s picture

Well, for those who has the same problem, here is a solution : https://www.drupal.org/node/2020325

spinsheet’s picture

I'm not using Panels and having the same issue. I applied patch #31 but the 'View draft' tab is still showing the published version while the 'Edit draft' tab allows editing the draft. I'm using Workbench Moderation 7.x-1.4.

I'm noticing this is only affecting custom fields. Anything in the Body field renders as expected. Anything in one of the page's custom fields only shows what is published even though you're viewing the 'View draft' tab. I've updated Entity API to its latest version but still not working.

chrisgross’s picture

This patch no longer applies to 1.x-dev. I tried to re-roll it, but it looks like this patch changes the same code modified by https://www.drupal.org/node/1838640

dgtlmoon’s picture

Status: Reviewed & tested by the community » Needs work

Since this was not committed and does not apply to 1.x-dev, updating status.

RumpledElf’s picture

I tried one of the patches further up the thread and it didn't apply. But what was in the patch worked.

Made a new patch, may help someone.

RumpledElf’s picture

StatusFileSize
new599 bytes
devin carlson’s picture

Version: 7.x-1.x-dev » 7.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new816 bytes

A reroll of #31 for 7.x-3.x.

mqanneh’s picture

Status: Needs review » Needs work

Tested with dev version and still having the same issue.
View draft will view the published version of the node.

jrglasgow’s picture

I saw the same issue but in testing with 7.x-3.x-dev I see that the issue is no longer there. It appears that this is a duplicate of #2021903 which was fixed last month with this commit http://drupalcode.org/workbench_moderation/commit/?id=11fdb6f

devaraj johnson’s picture

Still facing the issue any update on why it is not editing the proper revision