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.

Command icon 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:

Comments

yogesh kambari created an issue. See original summary.

yogesh kambari’s picture

Submitting below patch to unblock the scheduler flow in my project.

adinancenci’s picture

I have encountered a similar issue; it seems that something went wrong during installation because the node_field_data.publish_state and unpublish_state columns 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.

pameeela’s picture

Status: Active » Reviewed & tested by the community
Related issues: +#3556096: Moderation state fields are disabled on node forms, breaking Scheduler

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

acbramley’s picture

Status: Reviewed & tested by the community » Needs work

Hardcoding these states seems incredibly fragile, especially considering unpublished is a recent change (used to be archived?) so this wouldn't work for most sites.

pameeela’s picture

Yeah 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:

  1. It's possible to have a broken form and not know it, if the fields are hidden
  2. It should be possible to set a default per entity type so that you can hide the fields
bkosborne’s picture

Title: Publish_state and unpublish_state value is coming empty » Publish_state and unpublish_state values can be saved as empty if the form widgets are missing

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

pameeela’s picture

In 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!

smustgrave’s picture

Version: 2.0.0-beta2 » 3.0.x-dev
Assigned: yogesh kambari » Unassigned

smustgrave’s picture

Status: Needs work » Needs review

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

smustgrave’s picture

Status: Needs review » Closed (duplicate)

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

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.