2

I have a site that has a complex set of permissions and roles to support a workflow we have defined with Workbench Moderation. This particular workflow has the "normal" three states:

  • Draft
  • Needs Review
  • Published

The workflow is set up to allow both forward progression through the workflow (eg, Draft to Needs Review) and also backwards (eg, Needs Review to Draft). The site also uses the basic features in Workbench, and content creators like the My Content, My Drafts, and Needs Review, etc, pages / views that it provides.

OK, here is my problem. One of the common tasks are editors pushing nodes back to Draft status for original authors to do major work on. The problem is that if you examine node_save, revisions have their $uid set to the used who did the save (ie, $user->uid). In this case, it would be the editor. Therefore, the new draft shows up in the editor's queue and not the original author's (if you examine the view for this page, you can verify this behavior).

I am curious whether others have run into this problem and how they solved it.

Using a hook_node_presave to set the isn't an option, as it fires too soon, and node_save would nuke any changes, anyway.

I suspect that I could do a hook_node_update, eg

function mymodule_node_update ($node)
{
  db_update('node_revision')
    ->fields(array('uid' => $node->uid))
    ->condition('nid', $node->nid)
    ->condition('vid', $node->vid)
    ->execute();
}

but I am worried that there may be side effects that I am not considering.

Are there better options?

  • I have the same problem. I did some research and found this patch, but am still trying to get it to work: drupal.org/node/1240850#comment-6961580 -- Did you find a solution? – user17263 May 7 '13 at 0:21
4

Old question, but in response to the comment, this is the solution that I deployed. As far as I know, it has been working well: 

/**
 * Implements hook_node_update().
 */    
function mymodule_node_update($node) {
  db_update('node_revision')
    ->fields(array('uid' => $node->uid))
    ->condition('nid', $node->nid)
    ->condition('vid', $node->vid)
    ->execute();
}

/**
 * Implements hook_workbench_moderation_transition().
 */
function mymodule_workbench_moderation_transition($node, $previous_state, $new_state) {
  if (isset($node->nid) && isset($node->vid) && isset($node->uid)) {
    mymodule_node_update($node);
  }
}

This covers the case where a user updates a node via the edit form, and when a user pushes a node through moderation via the workflow forms.

  • These hooks work. I do not understand why this is not the default behavior of Workbench. It's only natural for content to passed back to the original content creator for further editing from an editor made some changes to the content. – Randell Jan 30 '14 at 23:30
  • are these hooks placed under the theme template? thanks! – Tom Vader May 15 '14 at 15:04
  • @TomVader No, they need to go in a custom module. – mpdonadio May 15 '14 at 15:12
  • It's working fine. – Deepak Kumar Aug 27 '14 at 10:10
1

Try the most recent patch over at Publishing/Unpublishing a revision changes the author of that revision. Or, if it's been committed, try a version of the module containing the fix.

1

I was having this same issue, and I was able to fix it by updating the "My Drafts" view to include revisions that belong to the current user OR revisions where the original node author is the current user.

I added the relationships Content Revision: Content (which links to the original node) and then Content: Author (using the content revision: content relationship)

I added the filter User: Current (Yes) using the relationship Content: Author (which uses the node's original author, instead of the revision author) and put it in an OR relationship with the extant User: Current filter.

https://www.drupal.org/node/2382215#comment-10471868

  • oranges#13 this views fix works great, but what if the last editor wasn't the original author? user1 creates the node. user2 edits the node and marks as "ready for review". user3 pushes "ready for review" back to "draft" in the current module as well as your view changes, user1 and user3 would see this node in the "my drafts" page. How could we get user2 to show this as well since that user was the last to edit. I'm trying to figure out if we can alter the view to do this or if I should try to make it so that somehow the revision_uid gets updated to the editor (in my example: user2) when the m – rdentry Dec 8 '16 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.