Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
[lhc/web/wiklou.git] / includes / libs / redis / RedisConnectionPool.php
index e3fc1a6..82cc233 100644 (file)
@@ -19,7 +19,6 @@
  *
  * @file
  * @defgroup Redis Redis
- * @author Aaron Schulz
  */
 
 use Psr\Log\LoggerAwareInterface;
@@ -82,9 +81,7 @@ class RedisConnectionPool implements LoggerAwareInterface {
                                __CLASS__ . ' requires a Redis client library. ' .
                                'See https://www.mediawiki.org/wiki/Redis#Setup' );
                }
-               $this->logger = isset( $options['logger'] )
-                       ? $options['logger']
-                       : new \Psr\Log\NullLogger();
+               $this->logger = $options['logger'] ?? new \Psr\Log\NullLogger();
                $this->connectTimeout = $options['connectTimeout'];
                $this->readTimeout = $options['readTimeout'];
                $this->persistent = $options['persistent'];
@@ -397,9 +394,14 @@ class RedisConnectionPool implements LoggerAwareInterface {
        function __destruct() {
                foreach ( $this->connections as $server => &$serverConnections ) {
                        foreach ( $serverConnections as $key => &$connection ) {
-                               /** @var Redis $conn */
-                               $conn = $connection['conn'];
-                               $conn->close();
+                               try {
+                                       /** @var Redis $conn */
+                                       $conn = $connection['conn'];
+                                       $conn->close();
+                               } catch ( RedisException $e ) {
+                                       // The destructor can be called on shutdown when random parts of the system
+                                       // have been destructed already, causing weird errors. Ignore them.
+                               }
                        }
                }
        }