Problem/Motivation
I'm trying to override the content_moderation.state_transition_validation to use my own class in order to provide a temporary solution to #2922266: Add permission to access all workflow transitions. This results in errors like:
TypeError: Argument 9 passed to Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget::__construct() must be an instance of Drupal\content_moderation\StateTransitionValidation, instance of Drupal\mymodule\StateTransitionValidation given, called in /var/www/docroot/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php on line 101 in Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget->__construct() (line 80 of core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php).
Proposed resolution
Any classes in content_moderation should use StateTransitionValidationInterface rather than StateTransitionValidation.
./tests/src/Unit/StateTransitionValidationTest.php
./src/Form/EntityModerationForm.php
./src/Plugin/Field/FieldWidget/ModerationStateWidget.php
Remaining tasks
Write a patch.
Comment | File | Size | Author |
---|---|---|---|
#11 | 2922285-11.patch | 4.25 KB | mstef |
#5 | 2922285-5.patch | 4.3 KB | timmillwood |
#2 | content_moderation-use_state_translation_validation_interface-2922285-2.patch | 4.13 KB | mstef |
Comments
Comment #2
mstef CreditAttribution: mstef commentedComment #3
timmillwoodGood catch!
Comment #4
catchDoesn't apply to 8.5.x
Comment #5
timmillwoodRe-roll for 8.5.x
Comment #6
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedLooks good!
Comment #7
catchCommitted/pushed to 8.5.x, thanks!
Comment #10
mstef CreditAttribution: mstef commentedThis is still not fixed in 8.4.x:
http://cgit.drupalcode.org/drupal/tree/core/modules/content_moderation/s...
Comment #11
mstef CreditAttribution: mstef commentedHere's a patch for 8.4-dev for reference if any one needs it.
Comment #12
jhedstromThis would be nice to backport to 8.4.x. Otherwise modules that need to decorate this service (#2906085: Content moderation integration: transition permissions and latest version access for instance) get fatal errors: