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

Issue fork facets-3199156

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mkalkbrenner created an issue. See original summary.

karlshea’s picture

It 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\SearchApiEvents at the top of SearchApiSubscriber.

Could it be that facets requires search_api in require-dev instead of require?

mkalkbrenner’s picture

Status: Active » Needs review

  • borisson_ committed a941c92 on 8.x-1.x authored by mkalkbrenner
    Issue #3199156 by mkalkbrenner: Drupal site install from existing config...
borisson_’s picture

Status: Needs review » Fixed

Sure this makes sense. Thanks @mkalkbrenner!

doubouil’s picture

This fixed my issue this morning, thanks! I also had to apply it to facets_summary EventSubscriber.

mkalkbrenner’s picture

Status: Fixed » Needs review

I looks like we discovered a core issue :-(

karlshea’s picture

What was the actual issue though? I don't see that pattern in all the other event subscribers.

mkalkbrenner’s picture

It only happens when you leverage the "install from existing config" feature:
drush site:install --existing-config

It 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.

heddn’s picture

module enablement should account for module dependencies.

dpolant’s picture

StatusFileSize
new819 bytes

We need to do the same thing for Facets Summary module. Here is a patch.

mkalkbrenner’s picture

The 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.

karlshea’s picture

Yikes.

flocondetoile’s picture

Status: Needs review » Reviewed & tested by the community

Met same issue when installing a new site from a factory, because facets_summary not yet fixed.

 [notice] Starting Drupal installation. This takes a while.
Error: Class 'Drupal\search_api\Event\SearchApiEvents' not found in /web/modules/contrib/facets/modules/facets_summary/src/EventSubscriber/SearchApiSubscriber.php on line 56 #0 /web/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php(37): Drupal\facets_summary\EventSubscriber\SearchApiSubscriber::getSubscribedEvents()

Patch #12 fix the issue.

mkalkbrenner’s picture

Title: Drupal site install from existing config is broken » Module installation is broken if search_api will be installed as dependency
heddn’s picture

There are no dependencies on search_api. Which explains the errors. +1 on RTBC.

pfrenssen’s picture

StatusFileSize
new1.14 KB
new351 bytes

I 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.

mkalkbrenner’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks for your help!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.