diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 803689b..94ad73f 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -285,6 +285,16 @@ public function getConnectionOptions() { } /** + * Returns the namespace of this Connection object. + * + * @return string + * The namespace of this connection object. + */ + public function getNamespace() { + return __NAMESPACE__; + } + + /** * Set the list of prefixes used by this database connection. * * @param array|string $prefix diff --git a/core/lib/Drupal/Core/Database/Log.php b/core/lib/Drupal/Core/Database/Log.php index 3f30665..aad111e 100644 --- a/core/lib/Drupal/Core/Database/Log.php +++ b/core/lib/Drupal/Core/Database/Log.php @@ -158,8 +158,8 @@ public function findCaller() { // database driver namespace. In any case, ensure the last entry of the // trace is returned. $is_driver_method = (strpos($stack[$i]['class'], $connection_namespace) === 0); - if (($is_driver_method === TRUE || $skipped_driver_methods === FALSE) && $i < $stack_count - 2) { - if ($is_driver_method === TRUE) { + if (($is_driver_method || !$skipped_driver_methods) && $i < $stack_count - 2) { + if ($is_driver_method) { $skipped_driver_methods = TRUE; } continue; @@ -185,7 +185,7 @@ public function findCaller() { * Namespace of the database connection. */ protected function getConnectionNamespace() { - return (new \ReflectionObject(Database::getConnection($this->connectionKey)))->getNamespaceName(); + return Database::getConnection($this->connectionKey)->getNamespace(); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php index 47f48e0..b77756a 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php @@ -276,7 +276,7 @@ public function testContribDriverLog($connection_namespace, array $expected_entr * Provides data for the testContribDriverLog test. * * @return array[] - * A simple array of simple arrays, each having the following elements: + * A associative array of simple arrays, each having the following elements: * - the contrib driver Connection class namespace * - the stack entry expected to be returned. * @@ -286,7 +286,7 @@ public function providerContribDriverLog() { return [ // Test that if the driver Connection is in the stack trace, the first // non-database entry is returned. - [ + 'contrib driver connection' => [ 'Drupal\\Driver\\Database\\dbal', [ 'class' => 'Drupal\\KernelTests\\Core\\Database\\LoggingTest', @@ -299,7 +299,7 @@ public function providerContribDriverLog() { ], // Test that if the driver Connection is not in the stack trace, the very // last backtrace entry is still returned. - [ + 'missing driver connection' => [ 'Drupal\\Driver\\Database\\fake', [ 'file' => '-',