I'm having an issue implementing a hook_workbench_moderation_transition() in my custom module.
The scenario is the following:
I have two custom states: "Unpublished" and "Rejected". I've setup the transitions in a way that I can essentially transition to either of these, while editing the node. Since the edit form always creates a new draft from the published version, the first hurdle was figuring out how to essentially re-build the logic in workbench_moderation_node_unpublish_form() to specifically allow me to transition from a revision that is *not* the live revision *and* simultaneously update the live revision to unpublished.
I was always ending up with a situation where the node is transitioned, but never got unpublished. I even wrote code to specifically change the 'status' field of the 'node' table to unpublished, but it mysteriously was always getting set back to published.
I finally figured out that what is happening is the shutdown function workbench_moderation_store() is being called *after* I run my transition to unpublish the live revision, but that function doesn't check well enough to see if there is a live revision anymore, and just saves the node as published anyway.
The fix was trivial, once I figured out what was going on. Patch in first comment.
Comment | File | Size | Author |
---|---|---|---|
#9 | workbench_moderation-allow-unpublish-live-revision-1875700-9.patch | 1.14 KB | Jelle_S |
Comments
Comment #1
jwilson3Comment #2
jwilson3Comment #3
jwilson3Here is the custom code you could model to test this out:
The actual error messages that are showing up in the logs after trying to run through transitions are the following:
And
Both errors were the result of not having a properly loaded node in the $live_revision variable of the shutdown function.
Comment #4
jwilson3Should be 7.x-1.x-dev... and also a patch that will apply.
Comment #5
ShaneOnABike CreditAttribution: ShaneOnABike commentedActually I discovered the same issue when enabling features it was pulling up this error message...
Any way that you could roll this through to 2.x also?
Thanks
Comment #6
jwilson3I personally dont have the need to re-roll this patch for 2.x nor do I have a project to test it on with 2.x, but did you look at the actual patch? -- it is 4 lines of code, you might try giving it a test, apply it by hand to your 2.x and if it works for you provide a reroll here. ;)
Comment #7
sinn CreditAttribution: sinn commentedjwilson3, try patch https://drupal.org/node/1436260#comment-7506957. I think it is more common fix
Comment #8
lolandese CreditAttribution: lolandese commentedComment #9
Jelle_SReroll