Problem/Motivation
The publish_state and unpublish_state values are coming up empty. This issue prevents content from being scheduled correctly based on moderation states. ( I can see "publish_state" and "unpublish_state" fields are present for entity)
Steps to reproduce
1) Install and enable Scheduler and Content Moderation modules.
2) Configure workflow settings (Add Moderation states, Transitions and Content type for which we need scheduler support)
3) Create a new node of that content type and:
- Set a future "Publish on" date.
- Set a future "Unpublish on" date.
4) Wait for the scheduled date to pass.
5) Run the cron job from UI.
6) Check the node’s status; it remains unchanged instead of being published/unpublished.
7) On debugging it is observed that "publishe_state" (in scheduler_content_moderation_integration_scheduler_publish_process) and "unpublish_state" (in scheduler_content_moderation_integration_scheduler_unpublish_process) are always coming empty.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | scheduler-publish-state-and-unpublish-state-value-empty-3507932.patch | 881 bytes | yogesh kambari |
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3507932-publishstate-and-unpublishstate
changes, plain diff MR !93
Comments
Comment #2
yogesh kambari commentedSubmitting below patch to unblock the scheduler flow in my project.
Comment #3
adinancenci commentedI have encountered a similar issue; it seems that something went wrong during installation because the
node_field_data.publish_stateandunpublish_statecolumns in the database were nowhere to be found.To fix the problem, I had to create the columns manually so I could uninstall the module and re-enable it, so it would properly create the columns in the database.
Comment #4
pameeela commentedWe just figured out scheduler was broken in Drupal CMS because the form fields were hidden. I think this patch makes a lot of sense to avoid having to expose two new fields on every node, if you are happy with the default values. Tested that it worked so marking RTBC but I don't have a deep understanding of this module so I understand if this fallback option is not desired.
Comment #5
acbramley commentedHardcoding these states seems incredibly fragile, especially considering
unpublishedis a recent change (used to be archived?) so this wouldn't work for most sites.Comment #6
pameeela commentedYeah I guess this is glossing over the problem anyway which is that you can set it up in a broken way.
There are two things that could be addressed:
Comment #7
bkosborneClarifying the title.
Note the issue in #3 is unrelated to the original report.
I agree that it should not be possible to save a node in an invalid state like this. The module does automatically set the field form widgets when its installed, but I guess that can either not work 100% of the time or someone accidentally reverts it without realizing.
Comment #8
pameeela commentedIn our case it was because the module was being enabled in a recipe that also contained the node edit form, and the fields were missing from that -- so definitely an issue in our config.
I do think it's strange to expose these values on every node, when most of the time it would be published/unpublished -- but that's a separate conversation!
Comment #9
smustgrave commentedComment #11
smustgrave commentedDisclosure since I give this module just a little bit of time a year I asked claude to have a look and to handle _none just in case.
Comment #13
smustgrave commentedActually closing as a duplicate of #3270462: Set a default value in the publish / unpublish state dropdowns as the same thing is being addressed for another issue.