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
Since we have a shiny new API for defining "internal" entity types from #2936714: Entity type definitions cannot be set as 'internal', we should leverage it in Content Moderation and don't allow internal entity types to be moderated.
Proposed resolution
Disallow moderation of internal entity types
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-12.txt | 3.63 KB | amateescu |
#12 | 2971779-12.patch | 2.48 KB | amateescu |
#8 | 2971779-8.patch | 3.56 KB | timmillwood |
#8 | interdiff-2971779-8.txt | 3.46 KB | timmillwood |
Comments
Comment #2
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedOur own
ContentModerationState
entity type has been marked as internal in #2941622: Make REST's EntityResource deriver exclude internal entity types and mark ContentModerationState entity type as internal instead of the current hack, and we also have a new internal entity type that we don't want to be moderatable,WorkspaceAssociation
from the new Workspace module in 8.6.This patch should do the trick.
Comment #3
timmillwoodLooks good to me.
Comment #4
alexpottDo we have test coverage? I looked in \Drupal\Tests\content_moderation\Kernel\EntityTypeInfoTest but I couldn't spot any.
Comment #5
timmillwoodI couldn't find a test that tested that "content_moderation_state" entity type wasn't moderatable, so here's one. It also checks entity_test which has lots of revisionable entity types which can be moderated, and an internal entity type "entity_test_no_label" to double check all internal types are not able to be moderated.
Comment #6
alexpottTo make the test more resilient to change I'd do something like
It also has no conditions which makes the test easier to understand and less prone to error. Basically it is more explicit.
Comment #7
alexpottSo yeah some of those types in the original patch and my suggested test don't exist because node and block are not installed...
Plus we don't actually need to call the alter manually - it's already applied to the definitions.
Comment #8
timmillwoodUpdating based on #7, with the added explicit check for non-revisionable entity types.
Comment #9
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI would have liked to see this test pick 1 test entity type for each cross section of criteria we are using for adding moderation.
That is:
Ideally the identity of each test entity type should be based on this criteria (ie, we use "entity_test_rev" for a revisionable entity type). I think doing this would mean:
That's my only feedback, if we'd rather maintain the list as a snapshot of all the entity types the test installs, then I'm happy to RTBC.
Comment #10
timmillwoodI think we need to test more than one of each type, so we might as well test all of them.
Although one anomaly is
entity_test_no_label
is internal but not revisionable, so I believe this test would still pass without the "fix".Comment #11
alexpottI agree with @Sam152 listing and testing all available entity types is not as useful as testing each specific situation.
Comment #12
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedAgreed with @Sam152 and @alexpott, there's no point in testing every entity type individually, we are just interested in a couple of characteristics here, (non-)revisionable and (non-)internal :)
Comment #13
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedLGTM
Isn't this equivalent to
$this->assertEquals($moderatable, $entity_types[$entity_type_id]->hasHandlerClass('moderation'))
?Not blocking RTBC on this, since I think you could consider it feedback on style.
Comment #14
alexpottCommitted and pushed 1e7cb6ac40 to 8.6.x and c6db9b2581 to 8.5.x. Thanks!
Backported to 8.5.x as I think this is really a bug and not a task.
Changed on commit - I ran the test locally and it passed. Nice idea @Sam152. Less conditionality in tests is always preferable.