diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index ed776bf551..23524650c2 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -618,6 +618,19 @@ public function discoverServiceProviders() { // Retrieve enabled modules and register their namespaces. if (!isset($this->moduleList)) { $extensions = $this->getConfigStorage()->read('core.extension'); + // If core.extension configuration does not exist then the container + // cannot be dumped because Drupal is yet to be installed. + if ($extensions === FALSE && $this->environment !== 'testing' && !InstallerKernel::installationAttempted()) { + $this->allowDumping = FALSE; + $this->containerNeedsDumping = FALSE; + // If we're not in the installer, register the installer service + // provider to ensure that cache tables are not created. This is + // required to correctly redirect to the installer without creating any + // incorrect caches. This is not required when the installer is running + // because the installer manages the addition of its own service + // providers. + $GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\InstallerServiceProvider'; + } $this->moduleList = isset($extensions['module']) ? $extensions['module'] : []; } $module_filenames = $this->getModuleFileNames(); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php index f5fb5dc225..141f047a3c 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php @@ -54,6 +54,17 @@ protected function prepareEnvironment() { mkdir($this->settings['settings']['config_sync_directory']->value, 0777, TRUE); } + /** + * Visits the interactive installer. + */ + protected function visitInstaller() { + // Should redirect to the installer. + $this->drupalGet($GLOBALS['base_url']); + // Ensure no database tables have been created yet. + $this->assertSame([], Database::getConnection()->schema()->findTables('%')); + $this->assertSession()->addressEquals($GLOBALS['base_url'] . '/core/install.php'); + } + /** * {@inheritdoc} */