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.
Part of meta-issue #2225347: [META] Replace calls to ENTITY_TYPE_load() and ENTITY_TYPE_load_multiple() with static method calls
See the detailed explanations and examples there.
Comment | File | Size | Author |
---|---|---|---|
#58 | replace_all_instances-2322509-58.patch | 100.9 KB | cilefen |
#53 | replace_all_instances-2322509-53.patch | 100.76 KB | gaurav.goyal |
#50 | replace_all_instances-2322509-50.patch | 100.85 KB | cilefen |
#50 | interdiff-48-50.txt | 680 bytes | cilefen |
#48 | replace_all_instances-2322509-48.patch | 100.37 KB | cilefen |
Comments
Comment #1
Temoor CreditAttribution: Temoor commentedComment #4
rosinegrean CreditAttribution: rosinegrean commentedI will recreate the patch.
Comment #5
rosinegrean CreditAttribution: rosinegrean commentedPatch recreated.
Comment #7
rosinegrean CreditAttribution: rosinegrean commentedFixed the test that failed.
Comment #8
rosinegrean CreditAttribution: rosinegrean commentedFixed the file extension.
Comment #9
cilefen CreditAttribution: cilefen commentedComment #10
rosinegrean CreditAttribution: rosinegrean commentedRerolled
Comment #12
rosinegrean CreditAttribution: rosinegrean commentedRerolled
Comment #13
cilefen CreditAttribution: cilefen commentedcore//modules/file/src/Tests/FileListingTest.php: $node = entity_load('node', $node->id());
core//modules/quickedit/src/Tests/QuickEditLoadingTest.php: $node = entity_load('node', 1);
There are two that were missed.
Comment #14
rosinegrean CreditAttribution: rosinegrean commentedComment #15
realityloopComment #16
rosinegrean CreditAttribution: rosinegrean commentedComment #17
jsobiecki CreditAttribution: jsobiecki commentedI'm working on review of this issue.
Comment #18
arejo CreditAttribution: arejo commentedReviewing.
Comment #19
jsobiecki CreditAttribution: jsobiecki commentedPatch looks ok for me (from static perspective). Changeset is huge (because it's major refactorization), but it's also very straightforwards (it's only replacement of node_load into Node::load, and in test cases, call to container of node entities in order to flush cache). Unfortunately, patch doesn't apply on latest version of Drupal, so it's require re-roll. I'm working on this.
Comment #20
jsobiecki CreditAttribution: jsobiecki commentedI updated patch, now it should apply cleanly. (Ops, missing attachment).
Comment #21
jsobiecki CreditAttribution: jsobiecki commentedComment #23
rosinegrean CreditAttribution: rosinegrean commentedFixed the fatal error in the previous patch.
Comment #24
realityloopI can't see any issues with the code in this patch and tests are passing.
Comment #25
alexpottNeed to inject the node storage here.
Should inject the node storage
Should inject the node storage.
Should inject the node storage
Should inject thr node storage.
Should inject the node storage
Comment #26
cilefen CreditAttribution: cilefen commentedThanks for the review @alexpott. I am working on #25.
Comment #27
cilefen CreditAttribution: cilefen commentedThis patch is for comments 1 and 2 from #25.
3, 4, 5, 6 are still undone.
Comment 3 concerns a static function so I am not clear how to inject things properly.
Comment #29
skipyT CreditAttribution: skipyT commented@alexpott: currently we have a big issue here. the commentController has some methods whose are strictly related to nodes. But the comments can be used on any entity. if we inject the node storage and we don't have the nodes activated we are getting these 4 tests failing.
the ideal solution would be to create a new service with the methods whose need the node storage injected. but I don't know if this is possible after the beta release.
Comment #30
cilefen CreditAttribution: cilefen commented@skipyT What if we inject the entity manager and check if the node storage exists?
Comment #31
skipyT CreditAttribution: skipyT commented@cilefen: yes, that would be the simplest solution. but i think it would be a hack. lets see what alexpott will reply.
Comment #32
alexpottLet's go with the idea in #30
Comment #33
rosinegrean CreditAttribution: rosinegrean commentedComment 3 from #25 is still undone.
Comment #37
rosinegrean CreditAttribution: rosinegrean commentedFixed the fatal error form #33
Comment #39
rosinegrean CreditAttribution: rosinegrean commentedFixed the fatal error from #37
Comment 3 from #25 is still undone.
Comment #41
rosinegrean CreditAttribution: rosinegrean commentedFixed the broken tests.
Comment #43
rosinegrean CreditAttribution: rosinegrean commentedRerolled
Comment #44
skipyT CreditAttribution: skipyT commenteduse $node_storage->load instead of Node::load where you already have the node storage.
Comment #45
rosinegrean CreditAttribution: rosinegrean commentedComment #46
skipyT CreditAttribution: skipyT commented@prics: not sure the replace_all_instances-2322509-45.patch is the good file uploaded. The interdiff shows you modified the code, but the patch is the old one.
Comment #47
rosinegrean CreditAttribution: rosinegrean commented@skipyT, good file, did not notice i was changing in BulkFormTest.php from node module. So I replaced Node::load() with $node_storage->load() where we already have the storage.
Comment #48
cilefen CreditAttribution: cilefen commentedRerolled because of #2304969: Port private files access bypass from SA-CORE-2014-003.
Comment #50
cilefen CreditAttribution: cilefen commentedComment #52
rpayanmComment #53
gaurav.goyal CreditAttribution: gaurav.goyal commentedPatch rerolled. Needs reroll tag removed.
Comment #54
rpayanmLook fine for me :)
Comment #57
rpayanmComment #58
cilefen CreditAttribution: cilefen commentedComment #59
rpayanmComment #60
alexpottThis change looks super disruptive but actually most of the changes are in tests and the other changes are making classes more honest by injecting the node storage as a dependency. This issue is a prioritized change (deprecated function removal) as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. These type of changes will be even better once #2372323: Static loaders on entity types don't return a properly typed object lands. Committed 5c3a1c6 and pushed to 8.0.x. Thanks!
Considering we're getting the node storage here we should just use it instead of the static loader.