Closed (fixed)
Project:
Facets
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Oct 2017 at 14:38 UTC
Updated:
1 Feb 2018 at 19:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
borisson_Setting to needs review for testbot.
Comment #4
borisson_Is this already committed? I think that's part of #2543726: Make $term->parent behave like any other entity reference field, to fix REST and Migrate support and de-customize its Views integration? As you can see this completely fails on the Integration tests.
Comment #5
berdirAlso, with it now being a proper field, maybe those queries could be converted to entity queries instead so we don't have to rely on the internal DB structure anymore?
Comment #6
wim leers🎉
Comment #7
larowlanThis is the wrong fix in my opinion.
It should be using the term storage handler, which has methods to fetch the hierarchy for you - and therefore will work with non sql entity storage.
The original code shouldn't interact with the tables direct.
IF we switched this to use the term storage handler, the code would work both now *and* after the core issue goes in
Comment #8
berdirIf we can indeed replace that code with methods from \Drupal\taxonomy\TermStorageInterface then that is definitely the best solution.
Also means that is not postponed but needs work and is major if not critical, as Drupal core will eventually break this. Maybe/hopefully in 8.5, if not then in 8.6.
Comment #9
borisson_If I understand this correctly, we should be using
\Drupal\taxonomy\TermStorageInterface::loadParentsto replace this? Sounds like a good solution. I didn't know about those methods, that really helps, thanks!Comment #10
larowlanYep those methods are part of the API and will stay, the implementation underneath is up to core to keep consistent
Comment #11
wim leers@borisson_ Let me know what I can do to help here. This is soft-blocking #2543726: Make $term->parent behave like any other entity reference field, to fix REST and Migrate support and de-customize its Views integration from landing in Drupal core 8.5, which in turn is blocking A) REST support for Term entities' parents, B) Migrate support for Term entities, C) more reliable Views integration for Term entities.
Comment #12
wim leersComment #13
borisson_I'm going to try to implement the suggestion made in #7 tonight, my personal laptop is broken so I'll probably have some fun first with setting up a dev env on my windows machine first.
So if I can get all of that to work it shouldn't be too hard to actually implement #7. I'd love to see a review when I get the patch up. I'll tag a new release to help with upgrades after we get this in.
Comment #14
wim leersGreat! I already rolled a patch for #2932067: Future patch to remove taxonomy_term_hierarchy.
Comment #15
wim leersComment #16
borisson_I tested unit and kernel tests locally and they are still green. Hopefully the integration tests still pass as well. No interdiff, because it's a new approach.
Comment #18
berdirthose methods AFAIK all have their own static cache, so you can probably remove that?
I don't think loadTree has the same structure through, that returns some weird object-not-really-entities thing by default. You probably want to get the ID's of those. Maybe you need to recursively call loadChildren() instead?
Comment #19
borisson_The tests that failed are now green locally, I also removed static cache, thanks @Berdir!
Comment #20
berdirYou seem to be using the $children variable twice now, once to load the children terms and once as a left-over of the static cache. I think you can just do return array_merge(); on the second-last line.
same here, you don't need $parent anymore.
Comment #21
borisson_Comment #22
borisson_Fixed a coding standards issue. Should now be ready.
Comment #23
berdirLooks pretty good to me visually.
One thing to point out is that those methods are not new in 8.x, they're basically a 1:1 port of helper functions in 7.x and earlier. So it is likely that they weren't used on purpose so far as this now loads the entities when we only need the ids. An entity query might be faster but that will only start to work with the core issue.
Comment #24
borisson_I tested this with ab, to make sure that @Berdir's worry wasn't too much. This was with all cache modules disabled. This is with 4 facets, 3 enabled and 1 with a taxonomy tree (with 12 items in it).
Without patch:
With patch:
So there is a difference but it is small. I think that with a bigger vocabulary there might be a bigger problem, so we should probably test that as well.
However, the increased readability and less complexity in the actual code is worth taking a small performance hit I think.
I'll try to test this again with a bigger vocabulary in the coming days.
Comment #25
wim leers… and the performance hit should disappear when updating to 8.6 (and hopefully #2543726: Make $term->parent behave like any other entity reference field, to fix REST and Migrate support and de-customize its Views integration will also still land in 8.5).
Comment #27
borisson_Committed and pushed, thanks so much for helping out and for all this information.
Comment #28
wim leers🎉