Skip to content

Commit

Permalink
Fix null being used for Redis connect timeout (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
tspencer244 authored Nov 10, 2023
1 parent a63cb17 commit 6e9677c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/Resque/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function __construct($server, $database = null, $client = null)
// $user is not used, only $password

// Look for known Redis options
$timeout = isset($options['timeout']) ? intval($options['timeout']) : null;
$timeout = isset($options['timeout']) ? floatval($options['timeout']) : null;
$persistent = isset($options['persistent']) ? $options['persistent'] : '';
$maxRetries = isset($options['max_connect_retries']) ? $options['max_connect_retries'] : 0;

Expand All @@ -143,9 +143,9 @@ public function __construct($server, $database = null, $client = null)

try {
if (is_string($persistent) && trim($persistent) !== '') {
$connected = $redis->pconnect($host, $port, $timeout, $persistent);
$connected = $redis->pconnect($host, $port, $timeout ?? 0.0, $persistent);
} else {
$connected = $redis->connect($host, $port, $timeout);
$connected = $redis->connect($host, $port, $timeout ?? 0.0);
}
} catch (\RedisException $e) {
$lastException = $e;
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -715,16 +715,6 @@ parameters:
count: 2
path: lib/Resque/Redis.php

-
message: "#^Parameter \\#3 \\$timeout of method Redis\\:\\:connect\\(\\) expects float, int\\|null given\\.$#"
count: 1
path: lib/Resque/Redis.php

-
message: "#^Parameter \\#3 \\$timeout of method Redis\\:\\:pconnect\\(\\) expects float, int\\|null given\\.$#"
count: 1
path: lib/Resque/Redis.php

-
message: "#^Property Resque_Redis\\:\\:\\$keyCommands type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down

0 comments on commit 6e9677c

Please sign in to comment.