In Workbench Moderation, edited versions of published nodes are saved as "draft". When clicking the "View draft" tab, which calls a URI like http://example.org/node/5/draft, a very basis 404 page is displayed:
<html><head></head><body>404 Not Found</body></html>
The problem can be traced to the call in workbench_moderation.node.inc
$router_item = menu_get_item('node/' . $node->nid);
which returns "restws_page_callback" for $router_item['page_callback']. (In a standard installation without restws, the return value is "node_page_view", and all works fine.)
The cause of the problem seems to be on lines 295 ff. of restws.module:
// @todo: Determine human readable URIs and redirect, if there is no
// page callback.
if (isset($page_callback)) {
// Further page callback arguments have been appended to our arguments.
$args = func_get_args();
return call_user_func_array($page_callback, array_slice($args, 2));
}
echo '404 Not Found';
drupal_add_http_header('Status', '404 Not Found');
drupal_page_footer();
exit;
Issue #1343816: Unconditional altering and overriding of existing menu links breaks comment permalinks and possibly others may be related to this one.
Comment | File | Size | Author |
---|---|---|---|
#49 | 1838640-tests.patch | 3.08 KB | Dave Reid |
#46 | 1838640-test-failure.patch | 3.63 KB | Dave Reid |
#37 | 1838640-fix-integration-with-restws-page-callback-altering.patch | 963 bytes | Dave Reid |
#33 | moderate tab revisions.png | 31.93 KB | jonas.fa |
#23 | workbench_moderation-fix_callback_argument-1838640-23.patch | 610 bytes | mallezie |
Comments
Comment #1
jneubert CreditAttribution: jneubert commentedThe attached patch is a workarround specifically for nodes.
Comment #2
jneubert CreditAttribution: jneubert commentedComment #3
jneubert CreditAttribution: jneubert commentedSame issue with 7.x-1.2
Comment #4
jneubert CreditAttribution: jneubert commented#1: restws-callback-1838640-1.patch queued for re-testing.
Comment #5
klausiThe 1.x branch is frozen and receives security updates only, please test against the 2.x branch.
Comment #6
jneubert CreditAttribution: jneubert commentedIssue occurs on 2.x also - patch adapted.
Comment #7
klausiThe problem is that workbench moderation does not invoke the menu callback correctly, the page arguments are missing.
Comment #8
paddy_deburca CreditAttribution: paddy_deburca commentedNot understanding the method that page arguments are passed between callbacks, I came up with the following code to solve _my_ problem between workbench_moderation and restws. in
workbench_moderation.node.inc
Comment #9
JeebsUK CreditAttribution: JeebsUK commentedAny idea if the suggested fix is likely to be confirmed as a potential valid solution? I'm currently working on a site where this is an issue but an awful lot of debugging is going to have to be done to ascertain whether we think this won't break or affect other things.
Comment #10
artsakenos CreditAttribution: artsakenos commentedI am working with
I tried:
state_machine, state_flow
with version 2.99+ as required, it didn't work, giving on a draft page call Fatal error: Call to undefined function state_flow_entity_load_state_machine() in state_flow/state_flow.module on line 78Then I built a patch according to suggestions in comment #8.
I performed some non exhaustive test on nodes and menu callbacks invoking, it works. Placing in review queue.
Comment #11
JeebsUK CreditAttribution: JeebsUK commentedWorks for us too - but we haven't performed exhaustive testing either.
Comment #12
rv0 CreditAttribution: rv0 commentedFixes it for me. Didn't perform any heavy testing.
Comment #13
das-peter CreditAttribution: das-peter commentedmenu.inc's
menu_execute_active_handler
does it this way:call_user_func_array($router_item['page_callback'], $router_item['page_arguments'])
I guess we should be as close as possible to that with the code in
workbench_moderation_router_item_page_callback()
.Comment #14
DamienMcKennaDoes it still apply against v7.x-1.x-dev?
Comment #16
rohit0122 CreditAttribution: rohit0122 commentedHello Friends,
While working with restws module, I came across a issue of "Node view draft" page is showing blank.
And at the same time if I try to access some other page I got warning of "Illegal offset type in restws_get_resource_info()" as follow:
For fixing such problem I have modify patch "workbench_moderation-fix_callback_argument-1838640-10.patch" a bit.
And after applying my modified patch, my issue get resolved.
Below is my patch file:
workbench_moderation-node_view_draft_page_fix-for-restws-mp-1356.patch
Regards,
Rohit S
Comment #17
dsteplight CreditAttribution: dsteplight commentedi just want to add that #1 also works for the 7.x-2.2 branch of the RESTful web services except the change needs to happen near line 372.
Comment #18
dafeder#16 worked for me on 7.x-2.3
Comment #20
mallezieI rerolled the patch in #16 to apply, the fix looks correct, and fixes the issues. This is the same of #10 (without an extra newline), and this should normally apply.
Comment #22
aschmoe CreditAttribution: aschmoe commentedNot sure why #20 is failing, here it is re-rolled today.
Comment #23
mallezieaschmoe, my patch uses the string 'node' as the first argument of the callback. You're patch creates warnings on the draft pages from rest-ws not able to define the resources.
Let's test attached patch which uses the callback approach from menu.inc as suggested in #13. It actually passes the same params as in #20 ('string node', string 'node_page_view', and node object).
Comment #24
mallezieAnd this does indeed pass tests. Yes!
Comment #25
jneubert CreditAttribution: jneubert commented#23 works fine for me with 7.x-1.3 and 7.x-1.4 - thanks!
Comment #26
zoheir.nabavi CreditAttribution: zoheir.nabavi commented#23 worked nicely. Thank you. How do we go about putting this in a dev branch?
Comment #27
mallezie@znabavi, if this works you could set it to RTBC, and then one of the maintainers could commit this.
Comment #28
zoheir.nabavi CreditAttribution: zoheir.nabavi commentedComment #29
dgtlmoon CreditAttribution: dgtlmoon commented+1 tested and working here, please commit
Comment #30
acouch CreditAttribution: acouch commentedDouble confirming this fixes the issue.
Comment #31
dkinzer CreditAttribution: dkinzer as a volunteer and commentedThanks @mallezie. This is fixing the issue for us.
Comment #32
daemonchrist CreditAttribution: daemonchrist commentedI tried the patch in #23 and found that it broke the View links under the Moderate tab: they all show only the currently published revision rather than the expected previous revisions. Is anyone else seeing this behavior, or is it just me?
Everything works as expected after reverting to the current stable release (with Restful web services disabled).
Comment #33
jonas.fa CreditAttribution: jonas.fa commented#23 patch works with estws-7x-2.4 and workbench_moderation-7.x-1.4.
@daemonchrist
We are using the above versions, and the "View"-links under the Moderate tab are working fine.
Comment #34
jonas.fa CreditAttribution: jonas.fa commentedEdit:
#23 does indeed break the "View"-links under Moderate tab. No matter which "View"-link is clicked, the same content is shown.
#10 do not have this behavior.
Comment #35
jonas.fa CreditAttribution: jonas.fa commentedI've found that replacing the $router['page_arguments'][2] with the $node argument in the workbench_moderation_router_item_page_callback() function, solves the problem described by #32.
The node return by menu_get_item() are the published node. Hence the use of $router_item['page_arguments'] in the fixed return call, always yield the same node content.
Anyone care to comment on the legitimacy of this hack?
Comment #36
Dave ReidThis definitely breaks the 'View draft' functionality for nodes, you see the published version and not the actual draft because we're no longer actually passing $node object (which contains the draft version) into the page callback.
Comment #37
Dave ReidIt's a shame that restws has to *prepend* it's page arguments instead of adding them on to the end, because it would be a lot easier to just have $page_arguments[0] = $node but we cannot rely on it being argument 0 with restws.
Comment #38
Dave ReidSince the previous patches broke functionality but passed tests, we need tests to cover this condition.
Comment #39
dgtlmoon CreditAttribution: dgtlmoon commentedDave - got a summary of the functionality it broke?
Comment #40
Dave ReidComment #42
Dave ReidCommitted the fix for now.
Comment #44
dgtlmoon CreditAttribution: dgtlmoon commentedAh, can you slow down a bit please, you are committing things that are in 'need work' and not updating their status after
Comment #45
Dave ReidNo, I committed it from Needs Review after I've been personally using it on a couple sites in production, so I felt confident in it. I'm working on the tests for this, which is why I marked it to Need work after commit.
Comment #46
Dave ReidThis should add test coverage for the fix, and with a partial revert of my fix shows that the new test fails.
Comment #49
Dave ReidTests only this time. This should pass.
Comment #51
Dave ReidCommitted the tests in #49 to 7.x-1.x.
Comment #53
dgtlmoon CreditAttribution: dgtlmoon commentedNice work! thanks!
Comment #54
Dave ReidFix needs to be applied to the 7.x-2.x branch if we're going to keep it open.
Comment #55
Devin Carlson CreditAttribution: Devin Carlson commentedIt looks like both the fix and the test have been added to Workbench Moderation 7.x-3.x.
http://cgit.drupalcode.org/workbench_moderation/commit/?h=7.x-3.x&id=635...
http://cgit.drupalcode.org/workbench_moderation/commit/?h=7.x-3.x&id=ef4...