I ran into a problem with the moderation form when rendered inside a Panels node view. Panels alters the node object by removing the node title so it is not rendered in the Panel pane. WB Moderation uses this altered node object when processing this form. When the node is moderated to publish, the node is saved in this altered state without a title.
My patch fixes this problem by sending the node_view moderation form a fresh node object using menu_get_object().
Since this moderation form is rendered from within the hook_view() function, it is expected that the $node object might be altered in some way, so I think this is the best way to go.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | moderation_form_should_not_use_altered_view_node-1245590-23.patch | 792 bytes | liam morland |
| #22 | moderation_form_should_not_use_altered_view_node-1245590-22.patch | 686 bytes | istryker |
| #21 | retaintitle.patch | 686 bytes | mpdonadio |
| #13 | retaintitle-1245590-12.patch | 791 bytes | azinck |
| #1 | moderate_unaltered_node_in_wb_moderation.patch | 944 bytes | nrambeck |
Comments
Comment #1
nrambeck commentedHere is my patch. It changes a single variable.
Comment #2
becw commentedHm, good catch! Does the same node object gets passed around everywhere, though? In that case, the node in
menu_get_object()would be the same object as the node post-hook_view(). Is it possible that Panels is misbehaving here by removing the title from the node object instead of messing with a render array somewhere and setting'#access' => FALSEor'#printed' => TRUEor something?I wonder if tests will run if I set this to "needs review"...
Comment #3
dave reidI'd also be inclined to say Panels might be doing the wrong thing by modifying the node object itself.
Comment #4
dave reidThe docs for hook_node_view() says modules should be modifying $node->content, not the node itself.
Comment #5
nrambeck commentedIt appears to me that there is no way for Panels/Ctools to render a node without the title using node_view except by unsetting the title. From what I can tell, you cannot affect the display of the title by modifying $node->content, so the only option is to modify $node->title. Other modules might reasonably do the same thing. If I'm wrong, I'll submit a bug report and patch to ctools.
Even if this was fixed somehow in Ctools though, I think it would still be proper to do some "defensive" coding and not save our moderated node after it has been passed to other modules for modification. If we can use a fresh node object that has not been passed around, I think we should do it.
Comment #6
cangeceiro commentedI am also running into this issue and the patch did resolve the issue with missing $node->title but it looks like it has b0rked the moderation form when viewing a draft. the select options are absent, and it appears to happen in the following logic
which is from workbench_moderation_moderate_form(). if i change the logic to
it works again, however i am not familiar enough with the inner workings of the module to know what this could break.
EDIT: it also looks like publish is not an option with the fix i described above
Comment #7
Taxoman commentedSubscribing
Comment #8
Greg Varga commentedSubscribing
Just a quick note confirming that this is still an issue in v1.0
Comment #9
Greg Varga commented*edited*
Sorry, the patch didn't work. It is causing issues. As described above, the Moderation box is disappeared.
Comment #10
stevectorChanging to 'needs work' because of the reported problems.
Comment #11
stevectorI wonder if we could get around this in another way. The problem phrased another way is that workbench_moderation_moderate_form_submit() can't trust the node object it is given. Does it need to be given a node object? What if workbench_moderation_moderate_form_submit() only had to trust a given nid/vid and loaded a node object from those and then called workbench_moderation_moderate_access() and workbench_moderation_moderate()?
Comment #12
nrambeck commented@stevector, I think that is right way to go.
Comment #13
azinck commentedBased on stevector's suggestion. Give this a try.
Comment #14
azinck commentedComment #15
jerdavisBumping priority of this for an actual fix, this is a pretty significant issue for anyone using workbench + panels.
We can work around this for now by removing the block, but we'd love to see what the approved solution is going to be.
Comment #16
stevectorjerdavis, have you tried the patch in #13?
Comment #17
mwallenberg commentedI tried the patch from #13, and can confirm that it works and solves the problem. Any chance to see this committed and released? I always feel a bit uncomfortable running on patched modules ;)
Comment #18
kristen polRTBC++
I have tested #13 and it works for me too. Thanks!
It would be great if this was committed soon.
Comment #19
mwallenberg commentedUpdated module to 7.x-1.2 and tested again. Still works.
Comment #20
liam morlandI am having this problem too, but with the link module and no panels. The patch in #13 fixes my problem too.
Changing the moderation state of a node should not update any records except those that relate to storing the moderation state.
Comment #21
mpdonadioThe patch from #13 applies to 1.2 with a little fuzz and seems to do the trick for me.
Here is a re-rolled version against 1.2.
Comment #22
istryker commentedI am rerolling this. @nrambeck & @matthew.donaido please read Advance patch contributor guide when you contribute a patch. This allows for good bug tracking for large projects.
Comment #23
liam morlandReroll.
Comment #24
liam morlandThis is a similar problem with a similar solution: #1737048: 2 URL aliases created when saving new node as published
Comment #25
stevectorThanks everybody: http://drupalcode.org/project/workbench_moderation.git/commitdiff/d0b0e7...