Issue #2491033 by daffie, mgifford, dawehner: Return value of Database::getLog() is inconsistent -- always return an array, even when empty
parent
8e04ab6b7f
commit
70a2d8c112
|
@ -129,7 +129,7 @@ abstract class Database {
|
||||||
*/
|
*/
|
||||||
final public static function getLog($logging_key, $key = 'default') {
|
final public static function getLog($logging_key, $key = 'default') {
|
||||||
if (empty(self::$logs[$key])) {
|
if (empty(self::$logs[$key])) {
|
||||||
return NULL;
|
return [];
|
||||||
}
|
}
|
||||||
$queries = self::$logs[$key]->get($logging_key);
|
$queries = self::$logs[$key]->get($logging_key);
|
||||||
self::$logs[$key]->end($logging_key);
|
self::$logs[$key]->end($logging_key);
|
||||||
|
|
|
@ -126,4 +126,13 @@ class LoggingTest extends DatabaseTestBase {
|
||||||
$this->assertEqual(count($queries2), 1, 'Correct number of queries recorded for second connection.');
|
$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.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue