summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2022-01-05 21:49:24 +0100
committerAndrey Andreev <narf@devilix.net>2022-01-05 21:49:24 +0100
commitc9a9d82bbc966c97876c2b6d5bc94ae3f4b4135f (patch)
tree22c7a9d3ed9bc4abeb08b312a8ee0db77691bc88 /system
parentf85ee8dd6a94529b6974d826b2018cc42dbd17cb (diff)
Fix #5562
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Cache/drivers/Cache_redis.php28
1 files changed, 12 insertions, 16 deletions
diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php
index 9b082d11b..e541237e3 100644
--- a/system/libraries/Cache/drivers/Cache_redis.php
+++ b/system/libraries/Cache/drivers/Cache_redis.php
@@ -95,6 +95,7 @@ class CI_Cache_redis extends CI_Driver
* if a Redis connection can't be established.
*
* @return void
+ * @throws RedisException
* @see Redis::connect()
*/
public function __construct()
@@ -132,26 +133,21 @@ class CI_Cache_redis extends CI_Driver
$this->_redis = new Redis();
- try
+ // The following calls used to be wrapped in a try ... catch
+ // and just log an error, but that only causes more errors later.
+ if ( ! $this->_redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout']))
{
- if ( ! $this->_redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout']))
- {
- log_message('error', 'Cache: Redis connection failed. Check your configuration.');
- }
-
- if (isset($config['password']) && ! $this->_redis->auth($config['password']))
- {
- log_message('error', 'Cache: Redis authentication failed.');
- }
+ log_message('error', 'Cache: Redis connection failed. Check your configuration.');
+ }
- if (isset($config['database']) && $config['database'] > 0 && ! $this->_redis->select($config['database']))
- {
- log_message('error', 'Cache: Redis select database failed.');
- }
+ if (isset($config['password']) && ! $this->_redis->auth($config['password']))
+ {
+ log_message('error', 'Cache: Redis authentication failed.');
}
- catch (RedisException $e)
+
+ if (isset($config['database']) && $config['database'] > 0 && ! $this->_redis->select($config['database']))
{
- log_message('error', 'Cache: Redis connection refused ('.$e->getMessage().')');
+ log_message('error', 'Cache: Redis select database failed.');
}
}