From a778ea13160cf3c087415dc8e35517c7785ee0a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Sun, 13 Aug 2017 14:18:18 +0000 Subject: [PATCH] Ignore errors in RedisConnectionPool destructor The destructor can be called on shutdown so any operation which relies on another object or resource can fail. E.g. running anything involving Redis (such as >>new Message('').''<<) from shell.php and then exiting will result in a RedisException since the PHP engine closes the Redis connection before destroying the connection pool. Such errors can be safely ignored. Change-Id: I38474a9dda89c82edbcb878facb4a97740e9189a --- includes/libs/redis/RedisConnectionPool.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/libs/redis/RedisConnectionPool.php b/includes/libs/redis/RedisConnectionPool.php index 99c2c3c287..509240f71c 100644 --- a/includes/libs/redis/RedisConnectionPool.php +++ b/includes/libs/redis/RedisConnectionPool.php @@ -396,9 +396,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. + } } } } -- 2.20.1