Skip to content

Commit a0673bc

Browse files
bug symfony#58260 [Cache] Fix RedisSentinel param types (Paweł Stasicki)
This PR was merged into the 5.4 branch. Discussion ---------- [Cache] Fix RedisSentinel param types | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT Parameters passed as strings from parse_url to \RedisSentinel constructor cause an exception. > RedisException : Invalid retry interval in /app/symfony/src/Symfony/Component/Cache/Traits/RedisTrait.php:236 Applies to redis-ext above 6.0.0 Commits ------- cf73c7e [Cache] Fix RedisSentinel params types
2 parents c8d5d4d + cf73c7e commit a0673bc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function setUpBeforeClass(): void
3333
throw new SkippedTestSuiteError('REDIS_SENTINEL_SERVICE env var is not defined.');
3434
}
3535

36-
self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['redis_sentinel' => $service, 'prefix' => 'prefix_']);
36+
self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']&timeout=0&retry_interval=0&read_timeout=0', ['redis_sentinel' => $service, 'prefix' => 'prefix_']);
3737
}
3838

3939
public function testInvalidDSNHasBothClusterAndSentinel()

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ public static function createConnection(string $dsn, array $options = [])
223223
$options = [
224224
'host' => $host,
225225
'port' => $port,
226-
'connectTimeout' => $params['timeout'],
226+
'connectTimeout' => (float) $params['timeout'],
227227
'persistent' => $params['persistent_id'],
228-
'retryInterval' => $params['retry_interval'],
229-
'readTimeout' => $params['read_timeout'],
228+
'retryInterval' => (int) $params['retry_interval'],
229+
'readTimeout' => (float) $params['read_timeout'],
230230
];
231231

232232
if ($passAuth) {

0 commit comments

Comments
 (0)