diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 08d64ad..791bf7a 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -1419,33 +1419,6 @@ public function quote($string, $parameter_type = \PDO::PARAM_STR) { } /** - * Checks if there the database is empty. - * - * @return bool - * Returns TRUE if there is an empty database for the connection. - */ - public function databaseEmpty() { - // Check for the presence of a database table provided in the hook_schema() - // implementation of a required core module. That should always be present - // if Drupal is already installed. - try { - return !$this->schema()->tableExists('sessions'); - } - catch (\Exception $e) { - // If we still have an exception at this point, we need to be careful - // since we should not redirect if the exception represents an error on an - // already-installed site (for example, if the database server went down). - // However a database error with code 1049 means "missing database", and - // it should be safe to redirect in that case. - return ($e instanceof \PDOException || $e instanceof DatabaseException) && $e->getCode() == 1049; - } - - // Default to FALSE to minimize the chance of overwriting an installed - // database. - return FALSE; - } - - /** * Prevents the database connection from being serialized. */ public function __sleep() { diff --git a/core/lib/Drupal/Core/Installer/CheckInstalledTrait.php b/core/lib/Drupal/Core/Installer/CheckInstalledTrait.php index f5fa91d..e7638a8 100644 --- a/core/lib/Drupal/Core/Installer/CheckInstalledTrait.php +++ b/core/lib/Drupal/Core/Installer/CheckInstalledTrait.php @@ -54,7 +54,37 @@ protected function shouldRedirectToInstaller(\Exception $exception, Connection $ // Redirect if the database is empty. if ($connection) { - return $connection->databaseEmpty(); + return $this->databaseEmpty($connection); + } + + // Default to FALSE to minimize the chance of overwriting an installed + // database. + return FALSE; + } + + /** + * Checks if the database is empty. + * + * @param \Drupal\Core\Database\Connection|null $connection $connection + * The drupal database connection to check. + * + * @return bool + * Returns TRUE if there is an empty database for the given connection. + */ + public function databaseEmpty(Connection $connection) { + // Check for the presence of a database table provided in the hook_schema() + // implementation of a required core module. That should always be present + // if Drupal is already installed. + try { + return !$connection->schema()->tableExists('sessions'); + } + catch (\Exception $e) { + // If we still have an exception at this point, we need to be careful + // since we should not redirect if the exception represents an error on an + // already-installed site (for example, if the database server went down). + // However a database error with code 1049 means "missing database", and + // it should be safe to redirect in that case. + return ($e instanceof \PDOException || $e instanceof DatabaseException) && $e->getCode() == 1049; } }