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
- Create a piece of content and schedule it for some time in the future.
- 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
- From the node edit form, click on the "Latest Revision" tab.
- From the Latest Revision page, Publish the node.
- Note that you are NOT prevented from doing so. In fact it seems that you are successful.
- 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.
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
Comment #2
sassafrass commentedNote: 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.
Comment #3
sassafrass commentedActually... 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.Comment #4
sassafrass commentedChanging title
and priority.. User error. Returning to Normal.Comment #5
sassafrass commentedI 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.
Comment #6
sassafrass commentedI 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:
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:
Comment #7
sassafrass commentedI 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.
Comment #8
smustgrave commentedFixes will need to be against 3.0.x
Comment #11
smustgrave commentedI 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.