diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php index dd19018..9092500 100644 --- a/core/lib/Drupal/Core/Database/Database.php +++ b/core/lib/Drupal/Core/Database/Database.php @@ -365,13 +365,11 @@ throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key); } - if (!empty(self::$databaseInfo[$key][$target]['namespace'])) { - $driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connection'; - } - else { + if (empty(self::$databaseInfo[$key][$target]['namespace'])) { // Fallback for Drupal 7 settings.php. - $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Connection"; + self::$databaseInfo[$key][$target]['namespace'] = "Drupal\\Core\\Database\\Driver\\{$driver}"; } + $driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connection'; $pdo_connection = $driver_class::open(self::$databaseInfo[$key][$target]); $new_connection = new $driver_class($pdo_connection, self::$databaseInfo[$key][$target]); diff --git a/core/lib/Drupal/Core/Database/Log.php b/core/lib/Drupal/Core/Database/Log.php index 13066f1..568cd11 100644 --- a/core/lib/Drupal/Core/Database/Log.php +++ b/core/lib/Drupal/Core/Database/Log.php @@ -185,8 +185,7 @@ public function findCaller() { * Namespace of the database connection. */ protected function getConnectionNamespace() { - $connection_class = get_class(Database::getConnection($this->connectionKey)); - return substr($connection_class, 0, strrpos($connection_class, '\\')); + return Database::getConnection($this->connectionKey)->getConnectionOptions()['namespace']; } /** diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php index b77756a..9d1f052 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php @@ -306,8 +306,8 @@ public function providerContribDriverLog() { 'line' => 52, 'function' => '__phpunit_run_isolated_test', 'args' => [], - 'class' => null, - 'type' => null, + 'class' => NULL, + 'type' => NULL, ] ], ];