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

arpieb’s picture

Status: Active » Needs review
StatusFileSize
new2.47 KB

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

mstef’s picture

Looks like it's working fine for me -- combined with the referenced patch.

arpieb’s picture

Re-rolled patch for 7.x-1.3 release

Status: Needs review » Needs work

The last submitted patch, workbench_moderation-unpublish-api-1781852-03.patch, failed testing.

arpieb’s picture

Version: 7.x-1.2 » 7.x-1.3
Status: Needs work » Needs review
pfrenssen’s picture

pfrenssen’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Component: Miscellaneous » Code
Category: support » feature
Status: Needs review » Needs work

I 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']->hid is not empty before executing the query. Otherwise this function will generate a warning if called for a node that has no published state.

recrit’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.6 KB
new912 bytes

re-rolled patch with added conditional check for $node->workbench_moderation['published']->hid.

dave reid’s picture

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

grasmash’s picture

Status: Needs review » Reviewed & tested by the community

I'm marking as RTBC because this patch applies cleanly and works.

aaron.ferris’s picture

Version: 7.x-1.x-dev » 7.x-1.4
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.02 KB

Came about some issues with this patch for 7.x-1.4, so re-rolled this into a new patch. Seems to apply correctly.

Status: Needs review » Needs work

The last submitted patch, 11: workbench_moderation-unpublish-api-1781852-1.4-reroll.patch, failed testing.

aaron.ferris’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Status: Needs work » Reviewed & tested by the community
aaron.ferris’s picture

Need to look at that patch as it's obviously failed simpletest, will reopen as 1.4 when I get a chance.

nitebreed’s picture

I'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?

davewilly’s picture

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

davewilly’s picture

Rerolled for 7.x-3.0

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: workbench_moderation-unpublish-api-1781852-3.0-reroll.patch, failed testing.

The last submitted patch, 17: workbench_moderation-unpublish-api-1781852-3.0-reroll.patch, failed testing.