diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php index e1a5c2a9589..8fe1c453eab 100644 --- a/core/lib/Drupal/Core/Database/Database.php +++ b/core/lib/Drupal/Core/Database/Database.php @@ -129,7 +129,7 @@ abstract class Database { */ final public static function getLog($logging_key, $key = 'default') { if (empty(self::$logs[$key])) { - return NULL; + return []; } $queries = self::$logs[$key]->get($logging_key); self::$logs[$key]->end($logging_key); diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php index f4ee580d94b..c354c8292b5 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php @@ -126,4 +126,13 @@ class LoggingTest extends DatabaseTestBase { $this->assertEqual(count($queries2), 1, 'Correct number of queries recorded for second connection.'); } + /** + * Tests that getLog with a wrong key return an empty array. + */ + function testGetLoggingWrongKey() { + $result = Database::getLog('wrong'); + + $this->assertEqual($result, [], 'The function getLog with a wrong key returns an empty array.'); + } + }