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
Setting an invalid moderation state on a moderated entity fails, but this is not tested..
Proposed resolution
Add test coverage.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2845113-4.patch | 1.06 KB | timmillwood |
Comments
Comment #2
tstoecklerNote that there is
ModerationStateConstraintValidator
which is related. Not sure if it could be re-used, but maybe yes.Comment #3
Sam152 CreditAttribution: Sam152 at PreviousNext commentedIt's a computed field which does actually get looked up from a workflow when being set and saved, so I would actually suspect that it's impossible right now to set it to something invalid.
Comment #4
timmillwoodRight, it is not possible to set moderation state to an invalid state, for example
$entity->moderation_state->value = 'foobar'; $entity->save();
throwsMaybe we need a test for this?
Comment #5
tstoecklerAhhh, I see we end up getting into
content_moderation_presave()
/EntityOperations::entityPresave()
which does$workflow->getState($entity->moderation_state->value)
and that throws the exception.Very interesting. Given that I do think it's worth having this test coverage, but it seems pointless to add an additional constraint, so re-titling. Thanks!
Comment #7
timmillwoodUnrelated test fail.
Comment #9
cilefen CreditAttribution: cilefen commentedUpdating credit.
Comment #12
cilefen CreditAttribution: cilefen commentedCommitted 95e9b9e and pushed to 8.4.x and cherry-picked as a straightforward testing improvement to 8.3.x as 9bb4595. Thanks!
Comment #13
xjm+1 for the backport as a testing improvement and experimental module. This looks good to me too.