Closed (fixed)
Project:
Search API
Version:
7.x-1.x-dev
Component:
General code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Dec 2017 at 09:24 UTC
Updated:
19 Mar 2022 at 08:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
graber commentedSolution: made the indexation registration happen as late as possible.
Comment #3
graber commentedComment #4
drunken monkeyThanks for creating this issue report!
While I appreciate that this might cause a problem in rare cases, I'm unsure whether this really warrants that additional code and complexity. It does seem like a rather "edgy" edge case – and with such code, there's always the possibility of now running into a different edge case.
So, thanks, but unless more people come out here in support of fixing this, I don't think I'll be committing this.
Comment #5
graber commentedI updated the issue title so people will find it easier. This caused many issues for a very long time on one large project I'm currently working on and was damn hard to debug, because of many possible causes and code beeing executed in shutdown functions. Hopefully it'll save someone a bit of struggle :)
As to edge cases - Yes, there may be a case where something would need to run after sending items to a search server and that patch would make it impossible. I fixed the issue by adding an extra late call of
_search_api_index_queued_itemson every admin page request in one of custom modules, quite similar as in the attached patch.Comment #6
donquixote commentedI think the problem applies only in specific scenarios.
We had this with search_api_et + workbench_moderation, and this site still has an older version of the latter. Not sure if the same would happen in a newer version.
Normally, without search_api_et, it would go like this:
If we look in node_save():
So the shutdown function from search_api would run after workbench_moderation, which is good.
But with search_api_et and entity_translation, we get this when a translation is saved:
Again, in hook_node_save():
There could also be other scenarios where the order of shutdown functions would be different, e.g. if another entity gets saved earlier in the request.
The same can be achieved in a simpler and more transparent way.
Comment #7
donquixote commentedThe patch in #6 has a problem, if
search_api_index_specific_items_delayed()is called within another shutdown function. In that case, the prepended function is never called.Instead we need this:
Comment #8
mibfire commentedHere is the patch that fixes the issues what @donquixote mentioned in https://www.drupal.org/project/search_api/issues/2930706#comment-13832461 comment.
Comment #9
drunken monkeyThanks a lot for your work on this. I just updated the comment and code style a bit (making the interdiff pretty useless, I guess …).
Could someone else please confirm that this works for them? Then I can commit.
Comment #10
drunken monkeyCould someone please test this?
Comment #11
joel_osc commentedHi @drunkenmonkey, I just tested this patch and it works great! Thank-you to everyone for working on this. +1 for RBTC.
Comment #13
drunken monkeyGreat to hear, thanks for testing and reporting!
Committed. Thanks again, everyone!