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.
The entity system has the baked in assumption that an entity type is revisionable when a revision id is specified. This should be explicit and checking for being revisionable should be simple, so let's introduce EntityType::isRevisionable() which checks for the revision id key.
Comment | File | Size | Author |
---|---|---|---|
#19 | 2224549-16-entity-type-revisionable.patch | 5.09 KB | fago |
#18 | 2224549-18-entity-type-revisionable--content-entity-type.patch | 7.96 KB | tstoeckler |
#16 | 2224549-16-entity-type-revisionable.patch | 5.09 KB | tstoeckler |
Comments
Comment #1
fagoComment #2
plachI'd say we should mark the relevant entity types as revisionable :)
Comment #3
plachThat is:
Comment #4
plachComment #5
fagoAs described, the patch checks the revision id - so no need to separately mark them revisionable .
Comment #6
plachI still think we should be using an explicit entity key instead of relying on the revision key, to make revisionability more easily alterable, anyway let's discuss this in a follow-up...
Comment #7
fagook, or we can try to discuss at the ddd to speed up things :)
Comment #8
alexpottd8_entity_revisionable.patch no longer applies.
Comment #9
XanoRe-roll.
Comment #10
fagoRe-roll is good, back to RTBC.
Comment #11
fagoComment #12
tstoecklerYeah, I'm fine with this for now. @plach wants to make the entity key information non-mandatory and provide sensible defaults for them, in which case this has to become a separate property, but since this will centralize the check it should not be a problem to change the implementation at that point.
Also once we have it we can move isRevisionable() along with isTranslatable() onto ContentEntityTypeInterface
Comment #14
tstoeckler9: drupal_2224549_9.patch queued for re-testing.
Comment #16
tstoeckler- Fix unit test
- Switch from (bool) getKey() to hasKey() in isRevisionable()
Also providing a separate patch and interface for moving this method to ContentEntityTypeInterface. I personally think that's the better patch. It's certainly more correct and we will want to do that at some point, but maybe people will want to all appropriate methods at once. I.e. isTranslatable() should be on ContentEntityTypeInterface as well.
Comment #18
tstoecklerThis should fix the test failures for the second patch in #16.
Comment #19
fagoI don't think we can move this to ContentEntityTypeInterface as RevisionableInterface is a separate interface, which entity types may implement independently from ContentEntityTypeInterface. Besides that, it would be weird if you would have to check for ContentEntityTypeInterface before being able to call isRevisionable().
Therefore, I think the first patch from #16 is the one to go + reroll looks good (again). I'm re-uploading the patch to avoid confusion, no changes.
Comment #20
fagoComment #21
plach+1 on #19
Comment #23
catchCommitted/pushed to 8.x, thanks!