Believing that this was an issue with other modules installed. I created an vanilla install containing workbench access, and workbench moderation with all required modules. I then tested just workbench to insure it was operating correctly with two roles. (editor/publisher)
Next I installed Scheduler_workbench. using scheduler workbench, when Cron runs, the following happens:
- It will adjust the time of the "published" content.
- It will change the state from published to draft.
However it DOES NOT unpublish the actual content.
I am willing to provide anyone who pm's me, a copy of my vanilla build for testing/debugging purposes.
Thanks.
Comments
Comment #1
Laurent Ren commentedI had the same problem. The current unpublish function does only change the state.
To solve this problem, I added the following function to scheduler_workbench.module :
And removed the _scheduler_workbench_scheduler_unpublish which is useless.
EDIT : It would be good to add a condition with the following code :
variable_get('scheduler_unpublish_revision_' . $node->type, 0)in order to take into consideration the "create new revision" option during unpublishing.
Comment #2
hefox commentedPatch based on how workbench_moderation's form unpublished the live revision
Comment #3
hefox commentedThe patch...
Comment #4
figtree_development commentedThanks to Laurent Ren and hefox the patch submitted works! Please promote this in the next update.
Comment #5
hefox commentedFixed means the patch has been committed. Please see th Issue queue handbox about status and priorities (linked to below the said fields on the comment form)
Comment #6
puregin commentedI can confirm that this issue exists and that patch #3 fixes it.
Comment #7
q2_faith commentedPatch #3 fixes this issue. Thanks.
Comment #8
mccrodp commentedYes, the patch in #3 also worked for me. I tested it using "Create a new revision on unpublishing" checked and unchecked. It worked for both! Thank you.
Comment #9
istryker commentedIf you publish and unpublish a node in the same cron job this does not work.
Setting node->revision to 0 is hacky because in reality revision = 1;
Comment #10
istryker commentedNew patch attached. Works with both "Create a new revision on unpublishing"/"Create a new revision on publishing" checked and unchecked.
Key thing is to remove workbnech_moderation_store() call that workbench_moderation_moderate() and workbench_moderation_node_update() adds to drupal_register_shutdown_function(). What this does is resave the published node at the end of the page load. (took me forever to figure this one out).
Code is much cleaner I believe as we let node save all on its own (no pre stuff) then make the changes to workbench_moderation.
Other note: The variable get if state was defaulting to FALSE when it should be to workbench_moderation default publish/unpublish states.
Comment #11
istryker commentedForgot to change state to needs review
Comment #12
pfrenssenMaybe this is related to #1436260: Saving nodes outside Workbench Moderation leads to incorrect state transitions (e.g., "needs review" appearing as published)? That issue solves a bug in Workbench Moderation which caused problems with publication states. It's been quite some time ago so I might be mistaken on this.
Comment #13
istryker commentedI read through #1436260 and it would appear that it would help, but it does not. Attached is a screenshot of using workbench_moderation with patch #74 and no patch to scheduler_workbench. Used latest dev version of Scheduler too.
Tested:
Comment #14
istryker commentedFound one more problem. After the node is published, in _scheduler_workbnech_scheduler_publish() we call workbench_moderation_moderate(). This sets the published node's node revision status to 0. It plans to set it back to 1 on shutdown. We unset shutdown so we have to do it manually.
Comment #15
Justtry commented#14 Works great, thanks.
Comment #16
hwasem commentedI agree. #14 is unpublishing my nodes correctly.
Comment #17
geerlingguy commentedI spent a couple hours working with this patch and scheduled publication of moderated nodes, and it looks like, while this patch does help with unpublishing, it breaks the ability to have nodes published via scheduler correctly. Workbench needs to run it's magic in shutdown to get nodes published correctly, and this patch removes Workbench's ability to do so...
To be more specific, this is a little more 'edge case', but here's the process that fails with this patch:
Comment #18
istryker commented@geerlingguy, its been a few months since I looked at this, but this should still be accomplish with rules. node_save() gets fire on the correct node, then you should be able to hook into that.
in the shutdown, node_save gets run a second time on the same node, just to save it as the live revision. The re-save in shutdown is an ugly workaround, and should never have ever been implemented. It breaks multiple of other contribs. In the future it is probably going to be taken out.
Currently patch works, so I think I can RTBC.
Comment #19
geerlingguy commentedI respectfully disagree :)
We shouldn't build patches based on hopes/wishes—currently workbench does the re-save, and yes, it is terrible, ugly, and the cause of hundreds of wasted developer hours per month. And AFAICT, the shutdown function is going to remain for some time (is there an issue stating otherwise?), and if we break the (sad, annoying, but necessary) normal way Workbench Moderation works in this patch, it still needs work so it won't do that.
I've done a lot more testing over the weekend, and the patch breaks my use case, which is publishing related workbench-enabled content when a particular workbench-enabled node is published via scheduler. It works fine without this patch (which does seem to help with unpublishing, don't get me wrong!), but with this patch applied, workbench leaves all the related nodes (which are published using something like
workbench_moderation_moderate($node, 'published');) in an inconsistent state, since the shutdown function doesn't finish publishing them.And if you still think it's fine as-is, needs review would still be more appropriate, as I think we need more people to test this patch and make sure it doesn't break other workflows (plus, no RTBCing own patches ;-).
Comment #20
geerlingguy commentedOne other, slightly unrelated note: I'm getting the following errors when this patch is applied when publishing multiple nodes as per the test conditions above:
Comment #21
istryker commented@geerlingguy what rules are you using?
Comment #22
geerlingguy commentedThis is custom code; just adding in
hook_node_update():$node->workbench_moderation_state_new === 'published'), find all related nodes.workbench_moderation_moderate($node, 'published');Without this patch, all the related nodes are published when scheduler publishes a node that has nodes related to it. With the patch, the related nodes are half-published. They get
statusset to1in the node table, and they're published according to Workbench Moderation, but the latest record innode_revisionis still set to0.Therefore, when the node is loaded by Drupal,
$node->statusis0, meaning the nodes are inaccessible to users without admin privileges, don't show in views with the 'published: true' filter, etc.Full example:
Comment #23
abhishek-anand commentedThere is a problem with the patch
Here unset($callbacks[$callback]); will not work in case $callback is a array, and the will lead to the error:
Illegal offset type in unset scheduler_workbench.module:213So, I think workbench_moderation_store was still being called in shutdown.
I think how it should be is
Comment #24
troutdrupaldeveloper commentedI am having a very similar issue, see https://www.drupal.org/node/2652434.
Comment #25
liam morlandWe have been running the patch in #14 successfully for about two years.
Comment #26
pfrenssenThe problems reported in #19 and #23 are not yet addressed. This patch still needs work.
Comment #27
liam morlandHere is a re-roll that includes the change suggested in #23. It does not address the issue rasied in #19.