Skip to content

Commit

Permalink
Fix Redis 6 Sentinel error message detection. Refs #46
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmollenhour committed Aug 16, 2022
1 parent a79e3a0 commit f80354d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Cm/RedisSession/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <password> called without any password configured for the default user. Are you sure your configuration is correct?') === false)
) {
throw $e;
}
}
Expand Down

0 comments on commit f80354d

Please sign in to comment.