Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Mar 2015 at 08:49 UTC
Updated:
28 Jun 2015 at 23:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
arpitr commentedComment #2
arpitr commentedAdding patch to replace deprecated function calls.
Comment #4
a_thakur commentedComment #5
dpopdan commentedComment #6
lhangea commentedUpdating to needs review so that the patch is tested
Comment #8
jeroentCreated a new patch.
Comment #9
jeroentCoupled CR and created follow-up issue to remove the functions: #2465463: Remove deprecated taxonomy_* functions..
Comment #11
jeroent.
Comment #12
mile23Comment #13
mile23Some stuff to get started:
This method has enough occurrences of
getStorage()that you might just call it once and reference the manager. Like:Needs leading \ before the second class name.
Consolidate the calls to
getManager()like in #1 above.Test classes descending from
TestBasehave their own dependency-injected container for the mocked Drupal under test.So instead of saying
\Drupal::entityManager()you should say$this->container->get('entity.manager')For both of these, and for the other call to
getStorage()down below it, grab a reference to the storage manager at the top of the function, outside theforeach()loop, and then just call the methods on that inside the loop.Thanks!
Comment #14
mile23Note: this is kind of a duplicate of this one: #2405365: Remove usage of taxonomy_term_load_parents()
Comment #15
ajitsworking on it
Comment #16
ajitsTrying
Comment #18
tadityar commentedTrying.
Comment #20
jeroentHi tadityar,
Thank you for your patch.
I think the patch of AjitS (#16) is almost there, but there are still some failing tests in TermTest.php.
I haven't test it, but i think it's because the loadParents(), loadChildren() and loadTree() methods are directly called on the entitymanager instead of on the taxonomy storage.
So
should be changed to :
Comment #21
andypostupdated IS
Comment #22
ajits@JeroenT You are right. That was the fatal error!
Correcting the error for now. Will collect the taxonomy storage in a single variable in the next patch.
Comment #23
ajitsBack to needs work as per #13.
Will update the patch soon.
Comment #24
ajitsMoved the taxonomy storage to variables wherever possible. IMO, the priority of the issue is not minor, as getting the storage at 10 different places, unnecessarily, might have performance issues.
Comment #25
andypost2 more places to fix + docs error
I'd suggest to use interface here
\Drupal\taxonomy\TermStorageInterfacethat defines this methodsnot controller that could be swapped and there's no such thing *TSController*
Better to get the storage to separate variable here too
the same
Comment #26
tadityar commentedIs this correct?
Comment #27
andypostyep, thanx
Comment #28
xjmGreat work @tadityar -- this is looking good! Two points of feedback:
Any particular reason we're getting the entity manager from the available
$this->containerin some simpletests, but using the static method wrapper for the service in others? Not a big deal either way.In code comments, we should reference the default implementation of the service (class and method name), like the first hunk I've highlighted here does. So let's change the second hunk to do so as well.
Closed #2405365: Remove usage of taxonomy_term_load_parents() as a duplicate of this issue per #14. Thanks @Mile23.
Comment #29
mile23Speaking to #28.1, there is this issue which should provide some clarity, but doesn't: #2087751: [policy, no patch] Stop using $this->container in web tests
Comment #30
xjmAha, that's what I was thinking of. Thanks @Mile23.
Comment #31
tadityar commentedThank you for the reviews :)
Should this issue get postponed until something has been decided in #2087751: [policy, no patch] Stop using $this->container in web tests then? Or should I just revise the comments and leave the code as is?
Comment #32
xjm@tadityar, I think it's fine to leave them as you have in the patch, even though it's not quite consistent. If the policy is decided one way or another, there will be a whole lot to clean up. So I think it's just the second point, to reference the class in the docs. Thanks!
Comment #33
jeroentCreated straight reroll.
Patch attached.
Comment #34
jeroentAddressed #28.2 as suggested by xjm. Patch attached.
Comment #35
andypostLooks good to me
Comment #36
mile23My IDE couldn't find usages of taxonomy_term_load_parents(), taxonomy_term_load_children(), or taxonomy_get_tree() after applying the patch.
Comment #37
xjmThanks all! I confirmed that all three of these functions are deprecated for removal in 8.0.0 and that #2505851: Remove deprecated function taxonomy_* already has an attached change record for them. I also confirmed that no usages or references remain:
This issue is a prioritized change as per https://www.drupal.org/core/beta-changes and its benefits outweigh any disruption. Committed and pushed to 8.0.x.