I have rules and modules working on various content types. Some go from published to "expired". The rules action to set the moderation state to expired is unreliable and the rules action to unpublish is less reliable. I would like to call a function direct in the cron process to both unpublish and set the status to 0. I am going to use node_save for status=0. What should I call from workbench moderation to set the state?
The API appears to be all hooks, not functions callable by other modules.
Comments
Comment #1
arpieb commentedWe are running into the same problem with revision_scheduler not properly unpublishing nodes when they are moderated to an unpublished state. Here is a patch that moves the unpublish logic from the moderation form submit handler to a publicly callable function, and changes the submit handler to use the new function.
This code is leveraged in a patch I'm about to also submit on #1364718: Unpublish live revision.
Comment #2
mstef commentedLooks like it's working fine for me -- combined with the referenced patch.
Comment #3
arpieb commentedRe-rolled patch for 7.x-1.3 release
Comment #5
arpieb commentedComment #6
pfrenssen#3: workbench_moderation-unpublish-api-1781852-03.patch queued for re-testing.
Comment #7
pfrenssenI have implemented a similar approach. My use case was to unpublish a node when it is set to the "Offline" moderation state.
You should check if
$node->workbench_moderation['published']->hidis not empty before executing the query. Otherwise this function will generate a warning if called for a node that has no published state.Comment #8
recrit commentedre-rolled patch with added conditional check for
$node->workbench_moderation['published']->hid.Comment #9
dave reidIt would be nice if this logic could be contained inside workbench_moderation_moderate() instead of a separate call, so that when programmatic calls to transition a published revision to unpublished don't have to change their logic based on what states are being used.
Comment #10
grasmash commentedI'm marking as RTBC because this patch applies cleanly and works.
Comment #11
aaron.ferris commentedCame about some issues with this patch for 7.x-1.4, so re-rolled this into a new patch. Seems to apply correctly.
Comment #13
aaron.ferris commentedComment #14
aaron.ferris commentedNeed to look at that patch as it's obviously failed simpletest, will reopen as 1.4 when I get a chance.
Comment #15
nitebreedI've been using the patch in #11 for some time now on 7.x-1.4-dev. Due to the security update I'm updating to 7.x-3.0. Is this patch still needed?
Comment #16
davewilly commented@Nitebreed This patch just adds a public function which can be called to expire and unpublish nodes. If you still calling workbench_moderation_node_unpublish() in your existing codebase you'll still need this patch. We were using the patch in #8 but it no longer cleanly applies to 7.x-3.0, so I rerolled it.. only to realise #11 applies cleanly.
Comment #17
davewilly commentedRerolled for 7.x-3.0