Problem/Motivation
since the commit of #3198193: Deprecated hook_search_api_query_alter it is not possible anymore to install a a site from existing config:
You are about to:
* DROP all tables in your 'db' database.
// Do you want to continue?: yes.
[notice] Starting Drupal installation. This takes a while.
[notice] Performed install task: install_select_language
[notice] Performed install task: install_select_profile
[notice] Performed install task: install_load_profile
[notice] Performed install task: install_verify_requirements
[notice] Performed install task: install_verify_database_ready
[notice] Performed install task: install_base_system
[notice] Performed install task: install_bootstrap_full
[error] Error: Class 'Drupal\search_api\Event\SearchApiEvents' not found in Drupal\facets\EventSubscriber\SearchApiSubscriber::getSubscribedEvents() (line 53 of /var/www/html/web/modules/contrib/facets/src/EventSubscriber/SearchApiSubscriber.php) #0 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php(37): Drupal\facets\EventSubscriber\SearchApiSubscriber::getSubscribedEvents()
#1 /var/www/html/vendor/symfony/dependency-injection/Compiler/Compiler.php(94): Drupal\Core\DependencyInjection\Compiler\RegisterEventSubscribersPass->process(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#2 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(762): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#3 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(1293): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#4 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(898): Drupal\Core\DrupalKernel->compileContainer()
#5 /var/www/html/web/core/lib/Drupal/Core/Installer/InstallerKernel.php(20): Drupal\Core\DrupalKernel->initializeContainer()
#6 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(819): Drupal\Core\Installer\InstallerKernel->initializeContainer()
#7 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(583): Drupal\Core\DrupalKernel->updateModules(Array, Array)
#8 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(207): Drupal\Core\Extension\ModuleInstaller->updateKernel(Array)
#9 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install(Array, false)
#10 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(806): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, false)
#11 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(570): Drupal\Core\Config\ConfigImporter->processExtension('module', 'install', 'facets')
#12 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(507): Drupal\Core\Config\ConfigImporter->processExtensions(Array)
#13 /var/www/html/web/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php(31): Drupal\Core\Config\ConfigImporter->doSyncStep('processExtensio...', Array)
#14 /var/www/html/web/core/includes/batch.inc(295): Drupal\Core\Config\Importer\ConfigImporterBatch::process(Object(Drupal\Core\Config\ConfigImporter), 'processExtensio...', Array)
#15 /var/www/html/web/core/includes/form.inc(950): _batch_process()
#16 /var/www/html/web/core/includes/install.core.inc(647): batch_process(Object(Drupal\Core\Url), Object(Drupal\Core\Url))
#17 /var/www/html/web/core/includes/install.core.inc(565): install_run_task(Array, Array)
#18 /var/www/html/web/core/includes/install.core.inc(118): install_run_tasks(Array, Array)
#19 /var/www/html/vendor/drush/drush/includes/drush.inc(213): install_drupal(Object(Composer\Autoload\ClassLoader), Array, Array)
#20 /var/www/html/vendor/drush/drush/includes/drush.inc(197): drush_call_user_func_array('install_drupal', Array)
#21 /var/www/html/vendor/drush/drush/src/Commands/core/SiteInstallCommands.php(149): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array, Array)
#22 [internal function]: Drush\Commands\core\SiteInstallCommands->install('jarltech_shop', Array)
#23 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#24 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#25 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#26 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(311): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#27 /var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /var/www/html/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /var/www/html/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#34 /var/www/html/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/v...')
#35 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main()
#36 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#37 {main}.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
karlsheaIt looks like the events were added in #3023704: Convert hooks to events (https://www.drupal.org/node/3059866), which was search_api 8.x-1.14. What version are you requiring?
Also, is search_api installed at that point? If it can't find the class it could be a composer autoloader issue, since there's a
use Drupal\search_api\Event\SearchApiEventsat the top ofSearchApiSubscriber.Could it be that facets requires search_api in
require-devinstead ofrequire?Comment #4
mkalkbrennerComment #6
borisson_Sure this makes sense. Thanks @mkalkbrenner!
Comment #7
doubouilThis fixed my issue this morning, thanks! I also had to apply it to
facets_summaryEventSubscriber.Comment #8
mkalkbrennerI looks like we discovered a core issue :-(
Comment #9
karlsheaWhat was the actual issue though? I don't see that pattern in all the other event subscribers.
Comment #10
mkalkbrennerIt only happens when you leverage the "install from existing config" feature:
drush site:install --existing-configIt looks like this always installs the modules in alphabetical order, regardless of module weights and dependencies.
And it seems that it starts a discovery for event subscribers which want to subscribe for module installation events.
You could reproduce it by exporting your entire config and do an "install from existing config" afterwards.
Comment #11
heddnmodule enablement should account for module dependencies.
Comment #12
dpolant commentedWe need to do the same thing for Facets Summary module. Here is a patch.
Comment #13
mkalkbrennerThe issue is much bigger. It also happens with a normal module installation when the dependency (search_api) is not yet installed.
I opened a core issue: #3200062: EventSubscribers lead to fatal errors on module installation. Please read and comment there to create some attention.
Comment #14
mkalkbrennerOK, according to #2825358: Event class constants for event names can cause fatal errors when a module is installed I choose the correct pattern to "solve" the issue.
Comment #15
karlsheaYikes.
Comment #16
flocondetoileMet same issue when installing a new site from a factory, because facets_summary not yet fixed.
Patch #12 fix the issue.
Comment #17
mkalkbrennerComment #18
heddnThere are no dependencies on search_api. Which explains the errors. +1 on RTBC.
Comment #19
pfrenssenI think we need to also indicate that we are no longer supporting Search API versions below 1.14. I just updated Facets on a site using an older version of Search API and all facets vanished from the search page.
Comment #21
mkalkbrennerCommitted. Thanks for your help!