Cannot change moderation state of published content on Latest Revision form

Created on 27 June 2024, 6 months ago
Updated 11 August 2024, 5 months ago

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... ✨ Allow manual publish before future publish date Active
Not sure if this should be addressed there or not, but I'm cross posting for visibility.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sassafrass

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sassafrass
  • πŸ‡ΊπŸ‡ΈUnited States sassafrass

    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.

  • πŸ‡ΊπŸ‡ΈUnited States sassafrass

    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.

  • πŸ‡ΊπŸ‡ΈUnited States sassafrass

    Changing title and priority.

  • πŸ‡ΊπŸ‡ΈUnited States sassafrass

    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.

  • πŸ‡ΊπŸ‡ΈUnited States sassafrass

    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.
  • πŸ‡ΊπŸ‡ΈUnited States sassafrass

    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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Fixes will need to be against 3.0.x

Production build 0.71.5 2024