Commit 70a2d8c1 authored by xjm's avatar xjm

Issue #2491033 by daffie, mgifford, dawehner: Return value of...

Issue #2491033 by daffie, mgifford, dawehner: Return value of Database::getLog() is inconsistent -- always return an array, even when empty
parent 8e04ab6b
......@@ -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);
......
......@@ -126,4 +126,13 @@ function testEnableMultiConnectionLogging() {
$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.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment