From 6c0aa8dcc5df3b1b42804200d34205061d2cc9c2 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 11 Nov 2014 16:49:56 +0100 Subject: [PATCH] MonitoringBackend: handle null name in a nice way When we get null as a backend name, we load the default one. While we want to cache that null backend, it should still know about it's real name. --- .../library/Monitoring/Backend/MonitoringBackend.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index 18ae5a2ad..e18bd39a4 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -62,7 +62,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface { if (! array_key_exists($name, self::$instances)) { - $config = static::loadConfig($name); + list($foundName, $config) = static::loadConfig($name); $type = $config->get('type'); $class = implode( '\\', @@ -80,7 +80,10 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface ); } - self::$instances[$name] = new $class($name, $config); + self::$instances[$name] = new $class($foundName, $config); + if ($name === null) { + self::$instances[$foundName] = self::$instances[$name]; + } } return self::$instances[$name]; @@ -144,7 +147,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface foreach ($backends as $name => $config) { $count++; if ((bool) $config->get('disabled', false) === false) { - return $config; + return array($name, $config); } } @@ -174,7 +177,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface ); } - return $config; + return array($name, $config); } }