diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 18b60cc..a0adb9e 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -622,7 +622,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = // installed yet (i.e., if no $databases array has been defined in the // settings.php file) and we are not already installing. if (!Database::getConnectionInfo() && !drupal_installation_attempted() && PHP_SAPI !== 'cli') { - $response = new RedirectResponse($request->getBasePath() . '/core/install.php'); + $response = new RedirectResponse($request->getBasePath() . '/core/install.php', 302, ['Cache-Control' => 'no-cache']); } else { $this->boot(); @@ -668,7 +668,7 @@ protected function handleException(\Exception $e, $request, $type) { } if (PHP_SAPI !== 'cli' && $this->isNotInstalledException($e)) { - return new RedirectResponse($request->getBasePath() . '/core/install.php'); + return new RedirectResponse($request->getBasePath() . '/core/install.php', 302, ['Cache-Control' => 'no-cache']); } throw $e; @@ -689,16 +689,22 @@ protected function isNotInstalledException(\Exception $e) { return FALSE; } + // If we're already in the installer, don't worry about Drupal not being + // installed. + if (drupal_installation_attempted()) { + return FALSE; + } + // Code 1049 is "missing database". if ($e->getCode() == 1049) { return TRUE; } - // This weird set of conditions is how we detect that the error was the - // sessions table was missing, which indicates an uninstalled Drupal. - if ($e->getCode() == 0 - && strpos($e->getMessage(), 'SQLSTATE[42S02]') !== FALSE - && strpos($e->getMessage(), 'sessions') !== FALSE) { + // SQLSTATE[42S02] indicates a missing table. Since we should only get here + // in case a bootstrap step failed, we assume that whatever table is missing + // is missing because the installation is broken, incomplete, or not even + // started. + if ($e->getCode() == 0 && strpos($e->getMessage(), 'SQLSTATE[42S02]') !== FALSE) { return TRUE; }