Problem/Motivation

If I have a piece of content scheduled for the future and I navigate to the "Latest Revision" tab from the node edit page, I am not prevented from selecting a Publish state. A success message is displayed saying,

Node Title is scheduled to be published some-future-date.

The moderation state has been updated.

No error is displayed. However, no actual change is made either, the moderation state has NOT been updated. The user may think that they have directly published the content, when in fact it is still in an Unpublished state.

Steps to reproduce

  1. Create a piece of content and schedule it for some time in the future.
  2. Edit the content and try to Publish directly from the node edit form and note that you are prevented from doing so with a cryptic error message
  3. From the node edit form, click on the "Latest Revision" tab.
  4. From the Latest Revision page, Publish the node.
  5. Note that you are NOT prevented from doing so. In fact it seems that you are successful.
  6. Note that the node is still not Published and is still scheduled to be published.

Proposed resolution

There is a related issue in the Scheduler queue: https://www.drupal.org/project/scheduler/issues/3423200#project-issue-aj...
Not sure if this should be addressed there or not, but I'm cross posting for visibility.

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

sassafrass created an issue. See original summary.

sassafrass’s picture

Note: The cryptic message in step 2. says, "'The scheduled publishing state of Publish is not a valid transition from the current moderation state of Publish for this content.';" which is generated by the Drupal\scheduler_content_moderation_integration\Plugin\Validation\Constraint\ PublishStateConstraint class.

sassafrass’s picture

Actually... this may be even more significant than i initially thought. It seems that any Scheduled content cannot change its moderation state from the Latest Revision Form page. The state can only be changed from the node edit page.. User error. Sorry.

sassafrass’s picture

Title: Issue directly publishing scheduled content » Cannot change moderation state of published content on Latest Revision form
Priority: Normal » Major

Changing title and priority.. User error. Returning to Normal.

sassafrass’s picture

Priority: Major » Normal

I believe some of the errors I was experiencing have to do with somehow being able to not set the Published state and still schedule the content...which results in a cron error. I'm still investigating with my client.

sassafrass’s picture

I believe I have narrowed this down. The use case is specific to directly Publishing a scheduled piece of content. If the Moderation transition from Published to Published is not allowed, you get an error preventing you from directly publishing from the Node edit form. Nothing is changed. However, under the following scenario, content can be put in an unexpected state.

If you use the Node Revision Form and the Moderation transition from Published to Published IS NOT allowed by your workflow, the user is not prevented from selecting the Publish state. It appears successful except:

  • The Content Overview page shows the content as Unpublished.
  • The Node edit form shows the content as Published and hides the Publish on fields even though they are still set.
  • The Content Moderation page no longer displays the content.
  • The Scheduled Content page shows the content as still Scheduled.
  • Cron runs continually fail.

If the Moderation transition from Published to Published IS allowed by your workflow, the user is not prevented from selecting the Publish state. It appears successful except:

  • The Content Overview page shows the content as Unpublished.
  • The Node edit form shows the content as Published and hides the Publish on fields even though they are still set.
  • The Content Moderation page no longer displays the content.
  • The Scheduled Content page shows the content as still Scheduled.
  • Cron runs fail until the original content Scheduled time.
sassafrass’s picture

I have tried to add a hook_form_alter to the content_moderation_entity_moderation_form to add a custom validator that includes the PublishStateConstraintValidator from Drupal\scheduler_content_moderation_integration\Plugin\Validation\Constraint. Unfortunately, the PublishStateConstraintValidator expects the $value to come from the entity as opposed to the form. As a result, it is getting the current moderation_state from the node entity, rather than the new_state from the content_moderation_entity_moderation_form.

Without knowing what direction this module is planning on taking with respect to direct publishing of content, I don't know how best to contribute at this point.

smustgrave’s picture

Version: 2.x-dev » 3.0.x-dev

Fixes will need to be against 3.0.x

  • smustgrave committed f687e428 on 3.0.x
    feat: #3457690 Cannot change moderation state of published content on...
smustgrave’s picture

Status: Active » Fixed

I used claude code to help with the test coverage but added new constraint validator
https://git.drupalcode.org/project/scheduler_content_moderation_integrat...

Thanks for detailed ticket.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.