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.
The scene is this:
I installed and configured search_api and search_api_solr.
Then I wrapped it into a fetaure (features.module).
From drush running a "drush site-install" that installs the feature results in:
PHP Fatal error: Class 'Apache_Solr_Document' not found in sites/all/modules/contrib/search_api_solr/service.inc on line 278
I guess somethings gets loaded in an unexpected order during the install.
I managed to fix the issue doing a spl_autoload_register() in the constructor in service.inc.
See patch.
Comment | File | Size | Author |
---|---|---|---|
#6 | search_api_solr-1302406-autoload-install.patch | 592 bytes | Steven Jones |
#2 | 1302406--early-autoload-2.patch | 368 bytes | drunken monkey |
#1 | autoload_problem-1302406-1.patch | 382 bytes | arnested |
Comments
Comment #1
arnested CreditAttribution: arnested commentedComment #2
drunken monkeyDoes the attached patch (registering the autoloader in
hook_boot()
instead ofhook_init()
) help?In any case, I suspect Features (or Drush?) is at fault here, as I don't think a module's classes should be used without calling
hook_init()
.Comment #3
arnested CreditAttribution: arnested commentedUnfortunately your patch did not make any difference.
I agree with you on suspecting features or drush to do weird stuff - so although my patch works I don't consider it a nice solution.
I guess separating search_api and search_api_solr in different features (with the exported config in the last feature) would make a difference. I'll have to try that some day.
Comment #4
guillaumev CreditAttribution: guillaumev commentedSame issue here, but at the end of an installation profile installation, when cron runs... Note that the issue is there only when installing the platform through drush (no issue when installing manually)
Comment #5
Steven Jones CreditAttribution: Steven Jones commentedI'm seeing this issue too, and have a fix.
Comment #6
Steven Jones CreditAttribution: Steven Jones commentedThe following fixed the issue for me, which was to register the autoloader on
hook_install
because the hook_init doesn't get called until the next bootstrap of Drupal.Comment #7
drunken monkeyGreat, thanks a bunch!
Is this working for everyone else, too? Please test! (As I never had problems, I can't really verify.)
Comment #8
arnested CreditAttribution: arnested commentedSteven Jones' patch works for me as well!
And the explanation makes sense to me too :-)
Comment #9
drunken monkeyGreat, committed.
Thanks again, Steven!
Comment #10.0
(not verified) CreditAttribution: commented"Patch follows" => "See patch"