When using the VBO plugin to change revision moderation states, the state is properly changed then changed back to the original state all in the same action.
Environment:
- Drupal 7.15
- Workbench 1.1
- VBO 3.0
Process
I have a cloned workbench view of content revisions with a relationship to the full node. The content may exist in 1 of 4 moderation states. I added a VBO field to the view to allow editors the ability to change the moderation state for the current revision of multiple node entities. I've tried using the VBO field as a dropdown and as a button with no success. (See figure 1)
First:
I am asked for the moderation state to change them to. I get a dropdown with moderation states and an empty checkbox. (See figure 2)
Second:
If I proceed with the empty checkbox checked or unchecked, the revisions' moderation states are updated to the requested state, then immediately changed back to the original state, as indicated by the moderation log. (See figure 3)
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | workbench_moderation-vbo-revision-1787214-13.patch | 2.26 KB | BrockBoland |
| #12 | workbench_moderation-vbo-1787214-12.patch | 1.94 KB | BrockBoland |
| #9 | workbench_moderation-vbo-checkbox-and-invalid-state-change-1787214-9.patch | 1.85 KB | mstef |
| Figure 3.png | 27.89 KB | KeyboardCowboy | |
| Figure 2.png | 19.83 KB | KeyboardCowboy |
Comments
Comment #1
agentrickardPlease file issues against the proper module.
Comment #2
KeyboardCowboyMy apologies. I thought the issue was in how workbench was providing arguments to VBO. I'll dig back in and move this issue to the VBO queue if the problem still exists.
Comment #3
agentrickard@KeyboardCowboy
You misunderstand me. Workbench Moderation is the proper queue, not Workbench.
Comment #4
mstef commentedHere's the empty checkbox..
Comment #5
mstef commentedIt doesn't seem to make any sense..
During submit, the moderation takes place if that checkbox is checked or if you have permission. Why provide an unrestricted checkbox that allows you to bypass permissions?
I think..
1. The checkbox should be removed
2. The code that checks the checkbox's value should be removed.
3. An error message should print if you don't have permission for a given node.
4. The change in moderation needs to be fixed, because it doesn't work.
Comment #6
mstef commentedIt looks like the action isn't working because 2 records are inserted into the workbench_moderation_node_history table. I just used VBO to change a draft to published, and the first record did just that, but then a second record was inserted moving it back from published to draft.
Comment #7
mstef commentedworkbench_moderation_node_update() is executed after the VBO-induced moderation change. That call seems to be reverting the change.
Comment #8
mstef commentedAnd line 690 in workbench_moderation_node_update() is what does it...
Comment #9
mstef commentedHere's a patch that does all that I suggested in #5.
To avoid the revert of moderation in hook_node_update(), I set $node->workbench_moderation['updating_live_revision'] = array(TRUE) before running the moderation.
Comment #10
byrond commentedWhile attempting to use Views Bulk Operations to set the moderation state to Published on a group of nodes that were in Draft but had $node->status=1 (core "published"), the moderation state was changed to Published and then back to Draft. #9 fixed this issue and prevented another error I was getting:
The error message is a little unclear when the reason _workbench_moderation_moderate_access returns false is because of an invalid state transition (for example, the current state is the target state). Maybe, "Moderation state could not be changed for %node" would be better? There doesn't seem to be a way to get more detailed information from the access function, so maybe the error should be more generic.
Comment #11
BrockBoland commentedFound a problem with #9. If you have a node that has a published revision, and a newer draft, this can fail. The new call to
_workbench_moderation_moderate_access()fails because it's passing the published revision of the node. I think that a call toworkbench_moderation_node_current_load()is all that's needed. Trying this out now.Comment #12
BrockBoland commentedworkbench_moderation_node_current_load()did the trick.Comment #13
BrockBoland commentedAnother variation. I'm not proposing this for inclusion in the module, merely sharing it in case anyone else has the same needs.
For my client, I need the bulk update to create a new revision on the node, in order to track what users make what changes to nodes.
workbench_moderation_moderate()doesn't create a revision, so I replaced it with a call tonode_save().Furthermore, the
'behavior' => array('changes_property')defined on the action (inworkbench_moderation_action_info()) results in anode_save()call after the actual action function (workbench_moderation_set_state_action()) is run. This resulted in two new revisions, sincenode_save()was called twice: once in the action function, and again somewhere else up the chain.Only use this patch if you want the bulk state change to create a new revision on each node that's updated.
Comment #14
scotwith1tI don't need the additional revision when it's moderated, so #12 worked great for me. Thanks BrockBoland!!
Comment #15
scotwith1tSpoke too soon. I did a couple mass changes of moderation state (to approved, in my case), but when i do something else in the same VBO view, like promote 1 to front page or make sticky, it reverts it back to the default moderation state (back to needs review, in my case), including the ones I just approved...i wonder if the checkbox was just an incomplete implementation, seeing as it says something about "force the transition", seems like that might be important...never written a VBO action before, so i'd have to dig around to find out what's missing. i'll ask someone else to look at this with me as well.
Comment #16
scotwith1tWe didn't have time to really dig into this, so we just set the default_state to TRUE and hid the checkbox, but that didn't work either. seems something may be wrong with the permissions check here, but i can't really put my finger on it right now...will report back if we figure it out, but the VBO isn't working for us. perhaps it's corrected in -dev? might try that shortly...
Comment #17
tedstein commentedI just worked on the same site that scotself was having trouble with and it is now fixed.
#12 did the job.
This should go upstream: The checkbox is an un-finished feature (or just a security hole) and saving the node twice in the action is a bug.
Thanks mstef and BrockBoland.
Comment #18
hass commentedComment #19
robcarrThis fix could do with being committed to DEV. Patch at #13 cured all my VBO issues
Comment #20
ryanc commented#13 solved the issue for me.
Comment #21
Justtry commented+1, #13 works for me, thanks
Comment #23
colanComment #24
colanForgot to set this up for forward porting.
Comment #25
das-peter commentedDoes not apply to the 2.x branch, it uses State Machine / State Flow to manage the states - so no actions defined by our module.