Closed (fixed)
Project:
Search API
Version:
7.x-1.x-dev
Component:
Plugins
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 May 2012 at 15:26 UTC
Updated:
2 May 2013 at 15:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
adam_b commentedmore screenshots...
Comment #2
drunken monkeyPlease use the "Index hierarchy" data alteration to index all parent terms of a taxonomy term.
Comment #3
adam_b commentedTried this, but I get an error when I try and re-index the content: "The website encountered an unexpected error. Please try again later."
The only serious PHP error in the logs is
EntityMetadataWrapperException: Unable to get the data property parents_all as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 of /var/www/html/sites/all/modules/entity/includes/entity.wrapper.inc).The taxonomy is generated by http://drupal.org/project/location_taxonomize if that helps?
Comment #4
dynamicdan commentedI just tried to do something similar and got the exact same message.
I have the latest entity API version.
I'm not using any special taxonomy plugins. I have a regions taxonomy that has tags like Global -> Australia -> Victoria -> Melbourne
Either 'Index hierarchy' doesn't work or there is perhaps a requirement that all terms must have a parent?
Comment #5
dynamicdan commentedNote that my setting on the workflow tab for search_api was 'All parent terms'.
Comment #6
dynamicdan commentedHmmm.. better title needed to reflect original issue. Perhaps also another issue should be created.
Comment #7
travisc commentedSame issue using
Index hierarchy data alteration to index all parent terms of a taxonomy term.
EntityMetadataWrapperException: Unable to get the data property parents_all as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 of sites/all/modules/entity/includes/entity.wrapper.inc).edit: eh, never mind
Comment #8
grasmash commentedI'm also experiencing this problem
@travisc Did you fix the issue? If so, how?
Comment #9
alanom commentedSame issue as dynamicdan with a very similar case (regions taxonomy with nesting around 4 levels deep, set to Index Hierarchy - all parent terms). Curiously, it worked fine until I cleared the vocabulary and then added a few hundred new terms.
If anyone knows what causes this or has fixed it, it would be appreciated if they could share it.
In my case I'm using Taxonomy Edge module to make the hierarchy work more smoothly, but as no-one else has mentioned that module it sounds like it's unrelated.
A potentially relevant note - this happens during the indexing of specific content, not any content. It can index some batches and falls over on others. Not yet figured out anything meaningful about which cause it to fall over. Edit: I think (not confirmed) it's terms with both parents and children that cause it to fall over. My content with a term with no parents or children in a vocabulary where most other terms have one or both has indexed fine without this error.
Comment #10
alanom commentedWell, I've found one cause of this. It seems nothing actually stops to check if a term whose ID has been found in a field actually exists before trying to grab the parents.
When terms are deleted, fields that reference those terms just carry on sitting there like nothing happened, carrying the TID of a dead term, until the entity they are on is re-saved when they fail validation and finally fall off. So, if you've ever deleted a term that was used by being referenced in fields, unless you immediately loaded and re-saved all the content that referenced it, you'll get this error.
Hitting 'Save' on all my existing nodes fixed this for me in the short term (luckily it's a development version of a site without too much content). But that's only a temporary fix - as soon as a term that is in use is deleted, search indexing will fail again.
Unless there's something I've missed, I'd call that a major bug as deleting taxonomy terms is a standard Core behaviour, and here, a standard Core behaviour can cause a site's whole search feature to fail with server errors on indexing. People could easily launch production sites that seem stable, but where the search indexing will die a painful death when next indexed after a content editor innocently deletes a taxonomy term that is in use but no longer wanted or needed.
A proper fix will involve, at an appropriate point in the code, checking the term referred to in a term field actually exists before trying to get its parents. I don't know nearly enough about entity wrappers to know how to implement this, but the entity wrapper objects do contain the ID and information about type. I'd guess that the first foreach in
extractHierarchy()incallback_add_hierarchy()would be a suitable place to do it.Of course in an ideal world, the core Taxonomy (or, Entity) module would actually clean up reference fields when a term is deleted, but that's not going to happen any time soon. There's been an issue open on this matter for a year now, and, like almost every Core issue I've seen, most of the activity has been semantic arguments about whether it's a bug or not. There's a related contrib module at sandbox stage, so there has been some activity, but it doesn't look like they're really even past the "What approach is best?" stage yet. Based on my (limited) experience of Core issues I'd bet it won't be fixed in D7 Core before summer 2013 at the earliest.
(Of course, it's possible there's another cause as well. I'm seeing some other strange indexing issues - content not crashing but not indexing for unexplained reasons. Will add more info if I find anything useful...)
Comment #11
alanom commentedComment #12
alanom commentedHere's a sticky-plaster patch that fixes the problem for me. All this entity wrapper stuff means little to me, so this is probably not the best or most efficient approach, but it works for me and hasn't noticeably affected indexing performance.
Someone with more experience with Search API and Entity API entity wrappers should get involved.
The source of the problem on Search API side for me is the call to
$wrapper->$property->valueinextractHierarchy()in includes/callback_add_hierarchy.inc.This adds a simple check using entity_load() before preceding to check that, where it's a taxonomy term, that term actually exists. I'm guessing term being indexed have been or will get loaded into memory earlier or later on anyway, in which case that or this enitity_load call will simply get it from memory rather than hassling the database multiple additional times.
That said, there's probably a better way: but this seems to work for now.
Comment #13
Anonymous (not verified) commentedApplied patch from #12, works for me. Thanks.
Comment #14
brephraim commentedPatch didn't apply to latest, but manually coding in the change worked. Thanks!
Comment #15
Anonymous (not verified) commentedIs it possible to get the changes proposed by the patch in #12 into dev?
Comment #16
stockliasteroid commentedPatch works for me too, my indexing died with the same error...
Comment #17
Anonymous (not verified) commentedSince this seems to work, please commit. Thanks.
Comment #19
esclapes commentedRerolled patch against current dev branch. Can also be applied to 7.x-1.3 without problems. Worked as expected.
Comment #20
giorgio79 commentedThanks patch worked for me as well.
Comment #21
mvc#19 applies cleanly against 7.x-1.4 as well. thanks!
Comment #22
kubrt commentedRun into the same error after deleting some terms, applied #19 against 7.x-1.4 , all working fine again. Thanks for the patch and please commit.
Comment #23
giorgio79 commentedThe patch does not apply for me for 1.4
Comment #24
giorgio79 commentedScratch that. I already applied it once. :D Still works fine.
This patch also helps for simple hierarchical taxos, as hierarchy is not captured at all without this it seems.
Comment #25
Anonymous (not verified) commentedYup, applies cleanly to 1.4. Can we get this committed?
Comment #26
drunken monkeySorry for taking so long to get back to you. While your solution seems to work fine, it's a bit to specific for my taste – the same could happen with any other entity, too.
The attached patch should fix this in a type-independent manner, instead of just for taxonomy terms. Please test/review and we can hopefully get this committed soon.
Comment #27
schnitzel commentedpatch worked for me, had exactly the issue and now its indexing seamless
Comment #28
schnitzel commentedComment #29
drunken monkeyCommitted.
Thanks for testing, and thanks @ alanom and esclapes for your work!
Comment #31
errev commentedDid not work for me
got the error
git apply 1594762-18-deleted-terms-cause-indexing-crash.patch
error: patch failed: includes/callback_add_hierarchy.inc:234
error: includes/callback_add_hierarchy.inc: patch does not apply
What the final folder should be?
Is it enity folder?
Comment #32
mvc@errev: the patch was already committed. just download the latest dev version and it will be included.