Closed (fixed)
Project:
Search API Entity Translation
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2016 at 15:04 UTC
Updated:
11 Apr 2019 at 13:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kporras07 commentedThis patch fixes my issue by passing full item id to search_api_track_item_delete so that it can now how to delete it from server.
(It previously deleted the item from the tracking table because it was using the right Datasource Controller but the item wasn't deleted form server)
Comment #3
kporras07 commentedI forgot to update status :(
Comment #5
jseffel commentedSeems to work.
Comment #7
fmfpereira commentedDo not work for me, at least using commerce_product entity.
The main problem is that search_api_et_entity_delete (hook implementation) runs after the entity has been deleted from database.
search_api_track_item_delete calls search_api_get_datasource_controller($type)->trackItemDelete and at one point method getTrackableEntityIds() is called.
getTrackableEntityIds() checks database to see if entity exists on the base table, but since the entity has been deleted from database, the index is nor returned and the entity is not deleted.
search_api_track_item_delete should be executed before entity being removed from database, or at least for all the indexes the uses that entity type.
Comment #8
joel_osc commentedFrom the node.module code it appears that the delete hooks are called prior to the node being deleted. The most recent dev version of this module addresses building the proper IDs, however, I am still having a problem with nodes still stuck in the index. Here is a patch that worked for me, but I am no expert with SearchApi so I would appreciate any feedback from the maintainers and the community. Cheers.
Comment #9
joel_osc commentedComment #10
thomas.claes commentedLike fmfpereira already said
In DrupalCommerceEntityController->delete(), the commerce_product is first deleted and afterwards, the hook_entity_delete() is fired.
So we don't have a way to do 'predeletion'-operations on the commerce_product.
Comment #11
david.lopez commentedMy suggestion is just to send all the possible translations to the search_api and this will take care of it.
Comment #12
czigor commentedTested #11 and it works. It also makes sense to go through all enabled languages.
On our site we still have disabled language items in the index, although #2777767: Items are indexed also for Disabled languaegs should have fixed that. Therefore we still have items of disabled languages in the index after deleting the entity, but I think that's a different issue.
As per the question of running hook_entity_delete() before or after the db is updated I don't think we can do much. Even search_api removes items in search_api_entity_delete().
Comment #13
joel_osc commentedAgree to the approach, patch works for me as well.
Comment #14
ciss commentedThis feels unsafe. Shouldn't we fetch the translations via the ET translation handler?
Comment #15
lendude#14 makes sense, with the fix in #11 any entity with no translations (only 'und') would still not be deleted since that is not an active language.
This implements #14.
Comment #16
idebr commentedPatch works as expected for content entered as LANGUAGE_NONE as well as content that is assigned to a language and their entity translations.
Comment #17
idebr commentedComment #20
idebr commented