The scheduler time setting is not compatible with Drupal core workflow

Created on 22 July 2025, 25 days ago

Problem/Motivation

The scheduler time setting is not compatible with Drupal core workflow

Steps to reproduce

Reproduction steps 1
1. Open Drupal core workflow and schedule module
2. Set a node with publish schedule, set the status to draft, and set the publishing time to tomorrow
3. Then publish this node, and see that the content moderation status of the node is published on the edit page
4. Go to the content list page and see that the publishing status is still unpublished
Reproduction steps 2
Publish an already published node and set the scheduler time. This node will be displayed in unpublish status (I think this should not be modified in the code. The status of the node should be cleared, so that the user can manually cancel the publication)

Reason:
1. After the upgrade, hook_node_presave was changed to hook_entity_presave, resulting in the execution order becoming to execute hook_entity_presave under content_moderation first, and then execute scheduler hook_entity_presave (use hook_node_presave before upgrading, its execution order is earlier than hook_entity_presave)
2. The code in else $entity->setUnpublished(); The state modification will change the state passed by content_moderation to unpublish state

Reason:
1. After the upgrade, hook_node_presave was changed to hook_entity_presave, resulting in the execution order becoming to execute hook_entity_presave under content_moderation first, and then execute scheduler hook_entity_presave (use hook_node_presave before upgrading, its execution order is earlier than hook_entity_presave)
2. The code in else $entity->setUnpublished(); The state modification will change the state passed by content_moderation to unpublish state

Proposed resolution

1. Add a prompt "The entity is already published and cannot be scheduled for publishing" if the original entity is in the published state and the current entity is also in the published state
2. If the original entity is in the unpublished state, but the current entity is in the published state, then the time also needs to be cleared (publish immediately)
3. When unpulishing, if the current state of the original entity is unpublished and the current entity is also unpublished, clear the unpublish_on time directly and prompt that it has not been published and the unpublish_on time cannot be set
4. If the original entity is in the published state, but the current entity is in the unpublished state, then the unpublish_on time also needs to be cleared (unpublish immediately)

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

🇨🇳China randy tang

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

Comments & Activities

Production build 0.71.5 2024