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
The handlers, specifically NodeModerationHandler in Content Moderation have a lot of confusing code, they might not even be needed at all. There are also form alters in there, is that the best place to be doing them, are they even needed?
Proposed resolution
- Review, organise, and clean up the code.
- Comment throughout to make it clear why this stuff is happening here.
Comments
Comment #2
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedWe should also write test cases that fail if the code is removed, to prove that it's required.
Comment #3
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedTo address the form alters; it looks like these are there to enforce UI elements that control revisions to always be on. Both in the bundle configuration form for defaults and the entity form for specific items of content.
I don't think there is a way to determine how the entity type has decided to construct its entity form, so I don't think these can be removed. New revisions are already created automatically, but the question is if we want the UI to say a new revision will not be created when it really will. If we can live with that, then all of these can go.
Comment #4
timmillwoodI think the form alters can be moved to the actual form alter hook with either a switch on entity type, or a check if the element exists in the form array.
Comment #5
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe ironic part of this is the bundle alter handler serves a purpose but is currently broken. See #2843380: Remove dead code by way of enforceRevisionsBundleFormAlter.
Comment #7
tacituseu CreditAttribution: tacituseu commentedDidn't want to create an issue out of it, but
core/modules/content_moderation/src/EntityTypeInfo.php
contains leftover from times it was an 'entity_reference':Edit:
also
core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php
injectsStateTransitionValidation
but doesn't use itEdit 2:
moved to #2900421: Architectural review of the Content Moderation module
Comment #12
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commented