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.

Comments

nrambeck’s picture

Here is my patch. It changes a single variable.

becw’s picture

Status: Active » Needs review

Hm, 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' => FALSE or '#printed' => TRUE or something?

I wonder if tests will run if I set this to "needs review"...

dave reid’s picture

I'd also be inclined to say Panels might be doing the wrong thing by modifying the node object itself.

dave reid’s picture

The docs for hook_node_view() says modules should be modifying $node->content, not the node itself.

nrambeck’s picture

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

cangeceiro’s picture

I 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

 if ($my_revision->vid == $node->workbench_moderation['current']->vid
      && $next_states = workbench_moderation_states_next($my_revision->state, $user, $node->type)) {

which is from workbench_moderation_moderate_form(). if i change the logic to

if ($next_states = workbench_moderation_states_next($my_revision->state, $user, $node->type)) {

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

Taxoman’s picture

Subscribing

Greg Varga’s picture

Subscribing
Just a quick note confirming that this is still an issue in v1.0

Greg Varga’s picture

*edited*
Sorry, the patch didn't work. It is causing issues. As described above, the Moderation box is disappeared.

stevector’s picture

Status: Needs review » Needs work

Changing to 'needs work' because of the reported problems.

stevector’s picture

I 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()?

nrambeck’s picture

@stevector, I think that is right way to go.

azinck’s picture

StatusFileSize
new791 bytes

Based on stevector's suggestion. Give this a try.

azinck’s picture

Status: Needs work » Needs review
jerdavis’s picture

Priority: Normal » Critical

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

stevector’s picture

jerdavis, have you tried the patch in #13?

mwallenberg’s picture

Status: Needs review » Reviewed & tested by the community

I 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 ;)

kristen pol’s picture

RTBC++

I have tested #13 and it works for me too. Thanks!

It would be great if this was committed soon.

mwallenberg’s picture

Updated module to 7.x-1.2 and tested again. Still works.

liam morland’s picture

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

mpdonadio’s picture

StatusFileSize
new686 bytes

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

istryker’s picture

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

Patch naming conventions explained

The (unofficial) patch naming convention that has emerged from the community is:

[description]-[issue-number]-[comment-number].patch

liam morland’s picture

liam morland’s picture

This is a similar problem with a similar solution: #1737048: 2 URL aliases created when saving new node as published

stevector’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.