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.
I tried using the index hierarchy setting for taxonomy terms with all parents and on two websites I received following PHP error when indexing:
"Fatal error: Maximum function nesting level of '500' reached, aborting!" which is caused by SearchApiAlterAddHierarchy->extractHierarchy( ).
On another website it did work (at least not this error), so I'm not yet sure why this bug occurs. Likely it depends on the vocabulary.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1400882-index-hierarchy-parents-loop-2.patch | 907 bytes | fangel |
Comments
Comment #1
fangel CreditAttribution: fangel commentedI'm having the same issue - and I believe it's to do with
if (search_api_is_list_type($wrapper->type())) {
, that then tries to loop through each item - this doesn't appear to work, so it calls itself with the a wrapper that is still a list, and hence it repeats.It might only trigger if the taxonomy-field allows multiple values.
Comment #2
mh86 CreditAttribution: mh86 commentedI'm using the parents_all property on the term fields in the meanwhile (add the term reference field as relation first), works fine.
Comment #3
fangel CreditAttribution: fangel commentedHmm, I was wrong - it wasn't because of the type. It was because parents_all on taxonomy-terms includes itself as one of the parents (or so it seems). I tweaked the code to only call itself recursively if the term hadn't already been seen. This seems to solve the problem for me.
Comment #4
fangel CreditAttribution: fangel commentedYup, $wrapper->parents_all on a taxonomy-term does indeed return itself as one of its parents..
Here's my test-code:
Output
As seen, term-id 8916, has the parent 8915, which has the parent 8911 - but when getting the parents of 8916, it returns 3 because it includes itself.
So I believe I'm right in only recursing when the value we're looking at haven't already been added to
$values
. Otherwise we end up looking at the term itself again, which leads us straight back to where we just were.--
I haven't tested it, but because the recursion only seems to be limited by the property not being set or having an empty value, wouldn't simply looking at the parent-property also include all parents? Because it calls itself on the parent, which calls itself on it's parent etc until we no longer have a parent (ie the root term).
Comment #5
fangel CreditAttribution: fangel commentedMarking as needs-review so we can get people to test this out.
Comment #6
jsacksick CreditAttribution: jsacksick commentedI tested the patch and it worked for me.
Comment #7
bago CreditAttribution: bago commentedWorked for me too!
BTW after fixing this I found that the db backend doesn't correclty index parents if your field is a "single value term" field: http://drupal.org/node/1494502
Comment #8
jsacksick CreditAttribution: jsacksick commentedThis is fixing the other issue or creating it ?
Comment #9
bago CreditAttribution: bago commented@jsacksick: it doesn't fix or create it. I just reported it as "related" as in my case the indexing failed and I found this issue. I applied this patch and the indexing still failed, but then I discovered that I had 2 concurrent bugs and this patch fixes one of them (but I still couldn't index because of the other issue: now I found a workaround for the other issue and, with the help of the patch at #3, I can finally index my term hierarchies).
Comment #10
jsacksick CreditAttribution: jsacksick commentedCommited in the dev branch. Thanks.
Comment #11
fangel CreditAttribution: fangel commentedAwesome, thank you. (PS, you accidentally set the wrong author on the commit)
Comment #12
jsacksick CreditAttribution: jsacksick commentedSorry man... I did it quickly this morning...
Comment #13
jaypark CreditAttribution: jaypark commentedfangel, how are you getting any response other than
EntityMetadataWrapperException: Unknown data property field_group. in EntityStructureWrapper->getPropertyInfo() (line 339 of entity.wrapper.inc).
i get that response from
field_group is a term reference field (yes, for a term).
...i can't get any value inside data at all - gives a similar exception about unknown data property. when just printing out the wrapper contents, data is defined as "stdClass Object" type, not a property.
is $wrapper->field->value() not supported for anything other than nodes?
Comment #14
fangel CreditAttribution: fangel commentedJaypark, Hmm - I never tried fields on taxonomy-terms, but I have used entity-wrappers to get the contents of fields on users, so I believe they should work. What does print_r($w->value()) give you?
Also, this is a closed issue on a only-semi-related issue, so this really isn't the correct place to ask questions - just fyi.