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.
%feature in a menu item will trigger eventually search_api_get_service_info during bootstrap prior to 'init', meaning the alter isn't called on those pages and won't be till cache is cleared (because of how module_implements is cached).
Patch moves it to top, which isn't the best, but should work for both search modules.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2177793-hooks-not-in-time.patch | 1.43 KB | janusman |
#1 | 2177793-acquia_search_multi_subs-includes-1.patch | 1.2 KB | hefox |
Comments
Comment #1
hefox CreditAttribution: hefox commentedComment #2
Nick_vhCan you please explain this in more detail and show me how to replicate this behavior. There might be other ways around this?
Comment #3
hefox CreditAttribution: hefox commentedIf you expert acquia solr server information to a feature, and visit one of the pages that has the feature name in the url ( /diff for example), it calls feature_load that eventually calls search_api_get_service_info before hook_init, so the alter hook is never called. There may be others, but that'll likely mean either 1) patching features 2) moving around a lot of cold to not include based on what module exists, but instead check if module exists inside the alter/etc.
Comment #4
janusman CreditAttribution: janusman commentedThe patch is calling module_exists() early in the bootstrap process; I think that could be a problem.
Comment #5
janusman CreditAttribution: janusman at Acquia commentedWorking with @NickVh we actually tracked this down to the acquia_search_multi_subs_search_api_service_info_alter() hook being outside the main .module file.
New patch.
On a site where this failed, these were the steps to reproduce:
Before the patch:
drush cc all
Adding the patch seems to fix things.
Comment #6
janusman CreditAttribution: janusman at Acquia commentedMarking as RBTC:
I tested the patch with another broken site (which also breaks under the same circumstances) and can plainly see the patch fixes the problem.
Stepping thru code with XDebug seems to show these events are happening in an unpatched site:
* Saving a view triggers a menu rebuild
* During the menu rebuild, search_api_facetapi_facetapi_searcher_info() is triggered
* This in turn triggers search_api_get_service_info() which would need the acquia_search_multi_subs_search_api_service_info_alter() function already available in order for acquia_search_multi_subs to correctly override things.
* HOWEVER that function is located inside a file that was not loaded until acquia_search_multi_subs_init() is called later on... by then it's already too late.
So, the patch moves acquia_search_multi_subs_search_api_service_info_alter() from that later-included file into the main .module file, which is always available :)
Comment #7
janusman CreditAttribution: janusman at Acquia commentedUpping to major.
Comment #8
janusman CreditAttribution: janusman at Acquia commentedCommitted to 7.x-1.x-dev