As a prequel to #2705389: Selected content entities should extend EditorialContentEntityBase or RevisionableContentEntityBase Node entity should implement RevisionLogInterface.
I did start working on a patch, to make Node and BlockContent extend RevisionableContentEntityBase, but there is one big flaw. Node and BlockContent entities currently define similar fields to RevisionLogEntityTrait but use different names. If we wanted to do this there would've been three options:
- Within Node and BlockContent update alter the field definitions set by RevisionLogEntityTrait.
This is what I have done in the patch but it causes the getters and setters in RevisionLogEntityTrait not to work because they use a different name. - Introduce revision_created, revision_user, and revision_log_message entity keys, use these in RevisionLogEntityTrait instead of hardcoding field names.
We already do this for many other fields. - Update RevisionLogEntityTrait to use the field names already used in Node and BlockContent.
I don't understand why this wasn't done in the first place.
Instead I am just going to get Node and Block content to implement RevisionLogInterface. Starting with Node.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | interdiff.txt | 522 bytes | timmillwood |
| #14 | node_should_implement-2705433-14.patch | 2.88 KB | timmillwood |
Comments
Comment #2
timmillwoodComment #3
timmillwoodComment #4
bojanz commentedWhat we care about is the interface, the base class and trait are just a way to reduce boilerplate. It's fine if we can't.
So let's make NodeInterface and friends extend the new interface. Deprecate old methods that don't match (like Node's getRevisionAuthor(), since we now have getRevisionUser())
Comment #6
timmillwoodThis patch switches Node to implement RevisionLogInterface.
It looks like Block might be trickier as it doesn't yet have a Revision user or a Revision creation time.
Comment #7
amateescu commentedThe patch looks good to me, I only found one small thing:
This use statement is not needed anymore.
Comment #8
timmillwoodUpdated based on #7.
Comment #9
dawehnerNitpick, can be fixed on commit: We use
{@inheritdoc}Comment #10
timmillwoodUpdated based on #9.
Comment #11
catchShouldn't the deprecated methods like getRevisionAuthor call the new methods like getRevisionUser()? I realise they're one-liners but makes the deprecation more explicit.
Where we add the deprecation notices we should say 'Use Blah\Blah instead' as well.
Also needs a follow-up to remove the usage of the deprecated functions and switch to the new ones - for example in Node::preSave().
Comment #12
timmillwoodUpdated base on #11.
Comment #13
tormiMinor typo: User > Use :)
Comment #14
timmillwoodUpdated based on #13.
Comment #15
dawehnerPerfect!
Comment #16
alexpottCommitted f8fd764 and pushed to 8.2.x. Thanks!
Can we get a follow up to replace all usages? Ideally 8.2.0 will not have any. Also the reference to the method should be fully qualified.
Fix made on commit.
Comment #18
alexpottFiled #2718583: Remove deprecated usages of Node::setRevisionAuthorId() and Node::getRevisionAuthor()
Comment #20
quietone commentedpublish the change record