From f80354dc7c20caef29c881972a7966732c8c9bbd Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Tue, 16 Aug 2022 18:35:13 -0400 Subject: [PATCH] Fix Redis 6 Sentinel error message detection. Refs #46 --- src/Cm/RedisSession/Handler.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Cm/RedisSession/Handler.php b/src/Cm/RedisSession/Handler.php index 8dc1a02..83aec67 100644 --- a/src/Cm/RedisSession/Handler.php +++ b/src/Cm/RedisSession/Handler.php @@ -310,8 +310,11 @@ public function __construct(ConfigInterface $config, LoggerInterface $logger, $r try { $sentinelClient->auth($pass); } catch (\CredisException $e) { - // Prevent throwing exception if Sentinel has no password set - if($e->getCode() !== 0 || strpos($e->getMessage(),'ERR Client sent AUTH, but no password is set') === false) { + // Prevent throwing exception if Sentinel has no password set (error messages are different between redis 5 and redis 6) + if ($e->getCode() !== 0 || ( + strpos($e->getMessage(), 'ERR Client sent AUTH, but no password is set') === false && + strpos($e->getMessage(), 'ERR AUTH called without any password configured for the default user. Are you sure your configuration is correct?') === false) + ) { throw $e; } }