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
entity_revision_load()
and entity_revision_delete()
are marked as @deprecated
for removal before Drupal 9.0.0.
Proposed resolution
Replace usages of these deprecated methods with their service-based replacements:
\Drupal::entityTypeManager()->getStorage($entity_type)->loadRevision($revision_id);
\Drupal::entityTypeManager()->getStorage($entity_type)>deleteRevision($revision_id);
Remaining tasks
File an issue to remove these methods in Drupal 9.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff.txt | 979 bytes | timmillwood |
#13 | remove_entity_revision-2741249-13.patch | 6.79 KB | timmillwood |
Comments
Comment #2
Mile23Comment #3
Mile23Comment #4
Mile23The patch.
This isn't a meta because it's not that many replacements.
Comment #5
Mile23Comment #6
Mile23Wrong parent.
Comment #7
Mile23Rerolled.
Comment #8
Mile23Patch still applies to 8.3.x.
Removes all entity_revision* usages.
Re-running test.
Comment #9
daffie CreditAttribution: daffie commentedIn the test Drupal\field\Tests\FormTest on line 578 there is the following comment: "$entity = entity_revision_load($entity_type, $entity->getRevisionId());". Can we replace that usage also?
All other usages for entity_revision_load() and entity_revision_delete() have been removed from the code base. The patch looks great. Almost RTBC for me.
Comment #10
urvigala CreditAttribution: urvigala as a volunteer and at Blisstering Solutions commentedComment #11
sneha_surve CreditAttribution: sneha_surve commentedComment #12
sneha_surve CreditAttribution: sneha_surve commentedApplied patch as per said in #9.
Thanks!
Comment #13
timmillwoodMerging the patches in #7 and #12. Interdiff is based on #7.
Comment #14
daffie CreditAttribution: daffie commentedLooks good to me.
All usages for entity_revision_load() and entity_revision_delete() have been removed from the code base.
The patch looks great.
I have one nitpick left, but that can be done on commit.
Sorry for nitpicking, but if you do this multiline then the second and third lines should be only 2 spaces indented and not 4 spaces. As an alternative you can put it on a single line.
Comment #15
alexpottFixed on commit.
Committed 4d8efc4 and pushed to 8.3.x. Thanks!
Removed unused use on commit.
Comment #17
Eric_A CreditAttribution: Eric_A commentedThis is uncommenting code apart from replacing the deprecated function (and fixing indentation). Nothing seems to have broken, but quite a big change for this issue.
Comment #18
Eric_A CreditAttribution: Eric_A commentedSeriously, this either needs a revert or some feedback. Why did we bring back that dead code in #12 and #13? Was it on purpose or a by accident? We could have converted dead code without uncommenting, we could have deleted dead code, but bringing it back in a conversion issue without any comment whatsoever is.. weird.
Comment #20
Eric_A CreditAttribution: Eric_A commentedComment #21
alexpott@Eric_A it is a test - let's worry about the important things. The commenting out erroneously occurred in #1822000: Remove Drupal\field_test\Plugin\Entity\Type\TestEntity in favor of EntityTest (probably as part of getting the patch to work but was missed on review). The test is pretty meaningless - but it is hardly alone in that.
Comment #22
Eric_A CreditAttribution: Eric_A commentedHaving this in 8.3.x but not in 8.2.x does make it harder to port some 8.3.x patches or forward port 8.2.x patches, like for example coding standard patches.
So we had erroneous changes to FormTest twice, but luckily the test is pretty meaningless. Sigh, ok. Thanks for the feedback.
Comment #23
alexpott@Eric_A well in that case just target 8.3.x first and if there's energy to backport to 8.2.x so be it.
Comment #24
Eric_A CreditAttribution: Eric_A commentedI do understand there's some hesitance to cherry-pick this task to 8.2.x now that it is in beta, but is the above really the policy for 8.2.x bug fixes? That would be a shame, cause then 8.2.x became half dead right after 8.3.x opened. Some policies are hard to track, I thought the policy here was to open bug fixes against the current minor (Not sure if that would be 8.1.x or 8.2.x right now) even if we commit to the latest open branch first.