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.
ContentEntityStorageBase::setNewRevision and ContentEntityStorageBase::setDefaultLangcode don't return $this, making them un-chainable.
They should return $this
Comment | File | Size | Author |
---|---|---|---|
#2 | drupal-return_this_from_ContentEntityStorageBase-2839075.patch | 1.42 KB | AaronBauman |
Comments
Comment #2
AaronBaumanComment #4
cilefen CreditAttribution: cilefen commentedComment #5
cilefen CreditAttribution: cilefen commentedThe title is ContentEntityStorageBase, but don't you mean ContentEntityBase? As far as I know, adding a return where there was not one is allowed by the BC policy, but let's get an opinion.
Comment #6
AaronBaumanYes, you're right the patch is against ContentEntityBase and RevisionableInterface
Comment #8
cilefen CreditAttribution: cilefen commentedThis is an API improvement that should not break anybody's code. Let's add a tiny change record to alert developers.
Comment #11
borisson_This makes changes to
\Drupal\Core\Entity\ContentEntityBase::setNewRevision
and\Drupal\Core\Entity\ContentEntityBase::setDefaultLangcode
.I don't think it makes sense to do this for setDefaultLangcode, because that's not part of the public API. I can see why we want to do this for
setNewRevision
.Comment #12
joachim CreditAttribution: joachim as a volunteer commentedComment #14
jhedstromSetting to NW for the change record.
Tiny nit:
Since this method is defined on the
RevisionableInterface
, that dockblock should be updated to indicate that the object is returned.