Closed (fixed)
Project:
Scheduler
Version:
2.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2018 at 16:17 UTC
Updated:
30 Mar 2024 at 23:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rondog469 commentedComment #3
jonathan1055 commentedHi rondog469,
You are doing the right thing, and this module should behave in a similar way to D7 from the users perspective. Can you run your test again but before you run cron could you visit admin/content/scheduled and note if your node is showing as scheduled for publishing (and that it is not also scheduled for unpublishing. Then run cron after the publish-time has passed and visit admin/content/scheduled again, to see what it shows.
Secondly, when you edit the node after it has failed to get published, is the 'publish on' date still set, or is it removed?
Thirdly, are you sure this is not a cache problem? The node cache should be cleared when the content is published, but something might be stopping that from working.
By the way, what core verson are you using?
Jonathan
Comment #4
rondog469 commentedHi Jonathan and thanks for the reply! I've been trying to figure this out since yesterday and now when I went to follow your steps, running cron after the publish time, it is now publishing...I have no idea..I tried this same thing at least 15 times yesterday.
To answer your questions:
1a. It was visible at /admin/content/scheduled before the publish time (see before-publish-time.png). It was not set for unpublishing at the same time if that is what you meant. I have been testing with a publish and unpublish time set, but they have been at least an hour past the publish time.
1b. Ran cron, and it worked this time! (see cron-run-after-publish-time.png)
2. The publish time is not set anymore. This was happening earlier when the module wasn't working for me as well as just now when I tried it and it worked. I assume that is the correct behavior (to remove the publish time)?
3. Not too sure. It seems to be working consistently now. I haven't changed anything since I made this post earlier.
I am using 8.5.3 and Scheduler 8.x-1.0. I accidentally selected this as a dev version issue.
Comment #5
jonathan1055 commentedWell, it's a mystery how your site has fixed itself, but at least everything seems to be working correctly now. Thanks for the screen shots.
If you notice it going wrong again then come back and update this issue.
Jonathan
Comment #6
rondog469 commentedWill do, thank you! Closing for now.
Comment #7
christiemade commentedIf you're still up for troubleshooting this one, I've got the same issue!
- Set a date to publish the unpublished node and save.
- The node shows up in /admin/content/scheduled with the correct 'Publish On' Date/Time and nothing in the 'Unpublish On' column
- After the time has passed, I run cron.
- Scheduler adds a watchdog entry 'Blog Post: scheduled publishing of [node title]'
- This node disappears entirely from /admin/content/scheduled
- This node is still unpublished and the Scheduled date setting has disappeared
I've tried running cron all around these steps but same results every time.
Comment #8
christiemade commentedComment #9
pfrenssenSetting to "Needs work" since there is no patch to review.
Comment #10
pfrenssen@christiemade, can you perhaps share the modules you have enabled in your project? It could be that there is some kind of interaction happening with another module that prevents the nodes from being published.
Comment #11
herczogzoltanLooks like src/SchedulerManager.php:180 sets the publish_on value to NULL for the node that being scheduled, and src/SchedulerManager.php:207 saves the node without this value (to prevent the node from being rescheduled again). However, in scheduler.module:345 there's a node presave hook which checks if the node has the publish_on value set, and if it's not, it sets the node's published status to false (scheduler.module:374). I uploaded a patch which publishes the node before saves it in ScheduleManager, but I have doubts that it's the right place to be. It worked for me on local after running the cron.
Comment #12
herczogzoltanComment #13
christiemade commentedI've confirmed it is another module interfering - it is 'Workbench moderation'
I've also confirmed that @herczogzoltan patch in #11 WORKS with Workbench moderation still enabled.
Huzzah!
Comment #14
pfrenssenGreat news! Seems like we have a working solution. This could still use a test on our end to ensure that this won't regress in the future.
Comment #15
jonathan1055 commentedI'm not sure what the problem is on #3022245: compatibility Workflow and Scheduler but the patch on that issue is making the same change in
SchedulerManager()as the patch here, so this might be related. It might also give more information on what is going wrong.Comment #16
ayalon commentedLong standing issue, never commited unfortuantly.
Here is a reroll for 1.2.0, Wir are carrying this patch for moths now in the composer.json of our LIVE systems.
Comment #17
herczogzoltanLooks like we need a test here, @pfernssen can you briefly share how should this be tested? I can write some tests in my spare time. :)
Comment #18
ejanus commentedI am nudging this thread. I am experiencing the same random issues as described in comment #11.
For reference, my project:
- Drupal 8.7.7
- Acquia Lightning 4.0.4
- PHP 7.2.21
Comment #19
jonathan1055 commentedHi ejanus,
Is it actually random? It seemed from christiemade in #13 that it is a conflict with Workbench Moderation. Do you have that module installed?
We need a list of steps to reproduce the error from a clean drupal install before we can attempt to fix the code. We can't write tests until we know why the code is wrong, not just that a particular line change fixes it for some circumstances.
Comment #20
ejanus commentedjonathan1055, thank you for keeping an eye on this. As soon as I have some time to dig into this more on my end and isolate the steps to reproduce as well as isolate the cause of the particular anomalies, I'm going to come back and provide that feedback.
I did notice we have the Scheduled Updates module installed and applied to one of our content types. Although, it is not used anymore and we will remove it in the future.
We currently use the scheduling provided by the lightning profile as described in their documentation:
Comment #21
karenann commentedI couldn't get either patch to apply running Workbench Moderation 8.x-1.5 and Scheduler 8.x-1.1.
I know that Workbench Moderation is deprecated, but, for those like me who haven't been able to allocate time to getting rid of it, I need this patch.
I'm rerolling it against Scheduler 8.x-1.1 in case anyone needs it.
Comment #22
omrmankarHello, @all I have shared this patch it is working for me. hope it will work for you guys also
Comment #23
karenann commentedI had been running the patch in #21 with 8.x-1.1 successfully. In my env, though, I have Workbench Moderation but I am using Scheduler on a content type that is NOT using moderation.
When I updated from 8.x-1.1 to 8.x-1.3, scheduled publishing stopped working, but unpublishing _did_ work correctly.
Neither the #21 patch nor the #22 patch solved my issue and so I reverted back to 8.x-1.1 with patch #21.
I don't have time to dig deeply into this right now, but when my time frees up, I'll check back here for developments or to participate in a solution. In any event, I at least wanted to share this info.
Comment #24
nicrodgersWe use workbench moderation and workbench moderation actions. We haven't needed to use this patch before, but we were using this patch #3038046: Cater for workbench_moderation_actions module removing node_publish action to support workbench moderation actions with scheduler 1.1.
When we upgraded from scheduler 1.1 to 1.3, all our scheduled publishing functionality stopped working.
I tracked the cause back to this patch #2824038: Node is saved twice.
Adding node->save() back in fixes it for us.
I haven't looked in to why this is happening or whether this only happens with WBM, but I assume it must be working as-is for non-WBM users as I can't find any related issues in the queue.
Longer term, I'm not sure if this is an appropriate fix or whether something else will be needed to ensure it works for WBM users and non-WBM users without doing an extra save. But at least if you use WBM this should get you back up and running on 1.3 for now.
Comment #25
jonathan1055 commentedHi nicrodgers,
Thanks for this. Do you know if removing that extra save in #2824038: Node is saved twice only affected those with WBM Actions? Or it is a problem if you just have WBM? That other issue was started in Nov 2016, but this one was only started June 2018.
If your patch does solve this issue I'd be OK with adding it back, inside the conditional
which we already have on the next line.
Comment #26
nicrodgersI don't think it's specific to WBMA, but would apply to anyone using WBM. I didn't have much time on the project last week so couldn't confirm either way, so it'd be great if anyone else could clarify.
Comment #27
fozzieblue commentedWe upgraded from scheduler 1.1 to 1.3, and now scheduled publishing isn't working.
We're on:
Here's what I did to test today:
I'm not sure which patch (if any) apply to a site not using workbench, but where scheduler isn't working. Should this be a new issue since it isn't a workbench conflict?
Comment #28
jonathan1055 commentedGiven that this issue is all about conflict with Workbench Moderation yes, you'd be better off making a new issue.
Comment #29
achap@jonathan1055 In answer to your question in #25 I am not using WBMA, just WBM by itself and am getting this same issue on 1.3. The patch from @nicrodgers works for me.
Comment #30
karenann commentedI'm coming back to this since I need to get ready for Drupal 9.
I am using Workbench Moderation (8.x-1.6) but not Workbench Moderation Actions.
I had been running Scheduler 8.x-1.1 with patch #21 only because the subsequent patches were not working.
I just upgraded to Scheduler 1.4. I have a content type which does NOT have workflows enabled for it. While I am getting all the expected alerts and log entries about scheduling happening and scheduled publishing, the content remains unpublished. I've modified my prototype according to the patches; adding the node save and injecting the setPublished, but still doesn't work.
I'll continue to poke at this to see if I can find a solution.
Comment #31
pghaemim commentedsimilar to #30, I'm not using the WBMA, just WBM, and had the issue of nodes, remaining unpublished. Saving the node similar to patch #24 works but I had to create a new patch for Scheduler 8.x-1.4.
Drupal 8.9.17
Scheduler 8.x-1.4
workbench_moderation 8.x-1.6
Comment #32
achapThis might actually be an upstream issue in workbench_moderation after all. I'm using the patch over in this issue queue https://www.drupal.org/project/workbench_moderation/issues/3238576
The wrong action plugin was being loaded. So when you were trying to publish a node, the unpublish_action was loaded, hence it was unpublished! That probably makes patch #24 redundant? I'm using that patch too but don't have time to test getting rid of right now.
Comment #33
jonathan1055 commentedThanks @achap for linking to that issue, it looks like a definite typo and could well be the cause of our problem.
I was not intending to commit either patch #24 or #31 here as neither of those felt the right thing to do in Scheduler.
If anyone else following this thread could test the patch on #3238576: Unpublishing content instead of publishing it and report back, that would be helpful.
Comment #34
jonathan1055 commentedI have commented on #3238576: Unpublishing content instead of publishing it again, as that bug does contribute to the problems reported here. The situation is complicated by the fact that (1) some users have Workbench Moderation only, whilst others also have Workbench Moderation Actions, and (2) the outcome of scheduling moderated nodes is different from non-moderated nodes.
Workbench Moderation is installed but not Workbench Moderation Actions
Non-moderated nodes should get published by Scheduler but they are not. This is due to the bug in the above issue. The scheduled publish_on date is removed, so it appears that the node has been processed, but the status remains unpublished.
Non-moderated nodes can be scheduled for unpublishing and this works fine, because the bug did not change the unpublish action.
Moderated nodes will not get processed by Scheduler at all because they are explicitly skipped via WBM Plugin/Action/ModerationOptOutPublishNode::execute and similarly for unpublishing. To schedule moderated nodes you need install WBMA ...
Both Workbench Moderation and Workbench Moderation Actions are installed
Non-moderated nodes are not being processed by Scheduler because WBMA exits out of the
StateChange::executeearly if the isModerated flag is false. Nothing is done, but the date remains on the node and the publishing is attempted again and again on each cron run. In the past, if non-moderated nodes were being processed ok by Scheduler then it was due to the quirk of having the extra save, which has now been removed between Scheduler 8.x-1.1 and 1.3.Moderated nodes are processed ok via Scheduler, and these do not need the extra save because the WBMA
executedoes a$entity->save()as expected. (There may be a problem with permissions not being set for anonymous during cron, and had to temporarily allow anon user all of the moderation transition permissions, but that's a separate issue.)The problem with non-moderated nodes requiring the extra save() when WMBA is installed can be worked out, I'm sure, either in Scheduler or in WBMA code.
[Note: all the testing above was on the Scheduler 8.x-1.x-dev branch. The 2.x branch may have slightly different outcomes .. that needs testing next]
Comment #35
achap@jonathan1055 Thanks for looking into it. I have some automated tests setup for the project I'm working on to test scheduled functionality for both a moderated and non-moderate node and found exactly the same thing as you. Also on the 8.x-1.x-dev branch
I tested removing patch #24 and keeping the workbench_moderation patch and it did indeed break the scheduled publishing/unpublishing functionality on moderated nodes. Non-moderated nodes that were scheduled were still working until I installed the WBMA module to try and get moderated node scheduling working. Now neither works :P I didn't have time to dig too deep into it but it did indeed seem to be permissions related for scheduling moderated nodes with WBMA.
Would it be feasible to get scheduling for moderated nodes working with just WBM? Ideally I wouldn't want to install another a module.
Happy to help with a patch(s) but not really sure in which direction to start or what needs to be fixed where.
Comment #36
jonathan1055 commentedThanks achap, good to hear that our testing and deductions match up.
The issue of non-moderated content not being processed properly by Scheduler when WBMA is installed should be fairly simple to fix, in either that module or in Scheduler. If need be, I can add an extra
$node->save()just when WBMA is installed (but there may be a more elegant way to solve it).In Scheduler I can probably also fix the workbench_moderation bug, using our own
hook_action_info_alter(). The WBM issue was created 8 months ago and there does not appear to be very active support/maintainership.In Drupal 7.x we had the Scheduler Workbench Integration project, and for the new Content Moderation available in core 8.2+ we have the fully-featured Scheduler Content Moderation Integration module. It would be a lot of work to replicate all the SCMI functionality for Workbench Moderation, which by definition will have an ever-decreasing user base. However I agree that it is not great to leave it in the currently broken state. When you want to schedule moderated nodes, what exactly is the scenario you are dealing with? I'm not certain exactly what WBMA intends to do when scheduling moderated nodes, although clearly it is meant to cope, because there are issues and comments talking about Scheduler. Adding the required permissions to the anon user for cron makes me think it's not been tried much for moderated nodes.
Comment #37
achapThe use case is we have nodes that our content team still want to go through approval process and publish manually but that also need to be able to be scheduled. I actually built my own integration for scheduler and workbench_moderation since there was none in D8. It acts on the PRE_UNPUBLISH, PRE_PUBLISH and STATE_TRANSITION events and syncs up the appropriate moderation states and correctly publishes/unpublishes moderated nodes.
I guess the double save from patch #24 was allowing the events to fire but now it never fires due to Plugin/Action/ModerationOptOutPublishNode::execute
So if there was a way to get the above events to fire without installing WBMA that would be ideal
Comment #38
jonathan1055 commentedThanks for the info @achap. I have worked out fixes for the two problems I stated in #36, and this needs to be done in Scheduler 2.x first, but I will port them back to 1.x also.
Your own custom Workbench Moderation integration using the Scheduler events sounds excellent. I think we should be able to devise a way to make that work and get round the OptOut problem. You could implement
hook_scheduler_publish_action()to do your work and include a node->save() then it would not matter if the OptOut caused the action processig to be skipped. Anyway, I am sure it can be done, but first I want to get the fixes in for the two problems above.Comment #40
jonathan1055 commentedStep 1 adds test coverage to check scheduled publishing and unpublishing when Workbench Moderation is also installed. This only tests non-moderated nodes so far. The test should fail, highlighting the error reported in #3238576: Unpublishing content instead of publishing it
Comment #41
jonathan1055 commentedThe test in #39 failed because I had not added workbench_moderation as a test dependency. Latest test should fail in the expected way, that is, node not published after cron.
Comment #42
jonathan1055 commentedStep 2 done - we have passing tests, showing that Scheduler can fix the Workbench Moderation bug and we are not reliant on that module getting the commit.
Comment #43
jonathan1055 commentedStep 3 - add test coverage for when Workbench Moderation Actions is also installed. This took a while, because I had to investigate and fix
#3281948: state_change__node__archived:configuration missing schema in functional tests to allow the test to run. This test will fail, demonstrating the scheduler problem found above.
Comment #44
jonathan1055 commentedAs expected, we get
Step 4 - The solution to this is that for non-moderated entities we want to skip the workbench_moderation_actions custom action. This will mean that we fall through to the old way of processing, because the core action will have been removed. But that is fine, as we already cater for it, and do
$entity->setPublished()->save()if the action does not exist.Comment #46
jonathan1055 commented@achap I'm going to commit the two fixes to each branch as this is a good step forward in allowing Workbench Moderation and Workbench Moderation Actions to be installed and not cause failures for non-moderated content.
Then we can work on the problem of moderated content.
Comment #49
achapAwesome @jonathan1055! I've just tested the 1.x-dev branch with your commits and it fixes my issues with non-moderatable entities i.e. my test passes. I uninstalled workbench_moderation_actions since I didn't want to install another module and implemented the hooks as suggested to fix my tests for moderatable entities. In case anyone needs the same I did this:
Thanks!
Comment #50
jonathan1055 commentedSo to wrap this up and summarise the situation:
Non-moderated nodes
Non-moderated nodes are now procesed correctly by Scheduler in both situations, that is when Workbench Moderation is installed and Workbench Moderation Actions both is and is not installed.
Moderated nodes
Moderated nodes are not processed by Scheduler, because they are explicitly skipped by the Workbench Moderation opt out.
To get round this, Workbench Moderation Actions was developed, and if WBMA is enabled then the moderated nodes are correctly processed by WBMA and scheduling works as expected.
If the site admin wants to have Scheduler and Workbench Moderation installed but not does not want to install Workbench Moderation Actions then they can solve the problem by implementing the two scheduler hooks in a similar way to the example provided by achap above. You may also need to implement an events subscriber to react to the scheduler pre_publish and pre_unpublish events and the workbench moderation state_transition event.
Following the commits above, and given that there are two solutions for resolving the conflict for moderated nodes, I'm going to mark this as fixed. The audience for Workbench Moderation is reducing, now that Core has Content Moderation. Scheduler has the fully functioning addon Scheduler Content Moderation Integration, which also now caters for any entity type supported by a Scheduler plugin.
Thanks everyone for sticking around and helping with this.
Comment #52
ronraney commentedI don't have Workbench Moderation installed, but I do have Workbench and Workbench Access. Our scheduling does not work and this issue is the closest I've been able to find to our own issue. Are Workbench and Workbench Access related to Workbench Moderation in any way? Is it the same family of modules?
Comment #53
khaldoon_masud commentedI solved this issue by installing the module https://www.drupal.org/project/advanced_scheduler, and implementing a custom hook:
You may need to modify module weight, so above hook runs after workbench_moderation_action_info_alter