Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
This is a conflict with #2856363: Path alias changes for draft revisions immediately leak into live site. The validator checks for defaultness which isn't set by the time the validator kicks in.
Reproduce:
- Edit a pending revision.
- Update the URL alias and click on a "published / default" state.
- See error where there should be none.
Proposed resolution
I think this will be fixed by taking the same approach as #2883868: Content Moderation decides to set a new revision as the default one way too late in the entity update process.
Comments
Comment #2
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #3
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #4
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe crux of the problem is, we need all of the default/publishing etc to take place at the API level when setting the
moderation_state
field for entity validations to work. We could update this in the field widget, so it would work at the form level, but$entity->validate()
would still be incorrect if you set themoderation_state
field manually.A custom list class would solve this, like we have with the computed field, we could then move most of
EntityOperations::entityPresave
toonChange
in the list class.This is quite a significant change however and it would essentially mean calling off to an entity handler method
onPresave
not actually during a presave, but any time themoderation_state
field is changed.The other option would be to stop delegating the responsibility of updating the default revision to the entity handler and essentially call
isDefaultRevision
/setNewRevision
twice.