Skip to content

Commit

Permalink
Merge pull request #18 from mficzel/bugfix/makeSentinelSettingNullable
Browse files Browse the repository at this point in the history
BUGFIX: Do not throw exceptions when `null` or `""` are used in `sentinels` setting
  • Loading branch information
robertlemke committed Nov 2, 2022
2 parents 88a764c + a677c62 commit 59af715
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Classes/RedisBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,18 @@ public function setPort($port): void
* If at least one Sentinel server is specified, this client operates in Sentinel mode
* and ignores "hostname" and "port".
*
* @param array|string $sentinels Sentinel server addresses, eg. ['tcp://10.101.213.145:26379', 'tcp://…'], or string with comma separated addresses
* @param array|string|null $sentinels Sentinel server addresses, eg. ['tcp://10.101.213.145:26379', 'tcp://…'], or string with comma separated addresses
*/
public function setSentinels($sentinels): void
{
if (is_string($sentinels)) {
$this->sentinels = explode(',', $sentinels);
if (is_null($sentinels)) {
$this->sentinels = [];
} elseif (is_string($sentinels)) {
if ($sentinels === '') {
$this->sentinels = [];
} else {
$this->sentinels = explode(',', $sentinels);
}
} elseif (is_array($sentinels)) {
$this->sentinels = $sentinels;
} else {
Expand Down

0 comments on commit 59af715

Please sign in to comment.