8000 [Cache] Only validate dbindex parameter when applicable · symfony/symfony@c5e997b · GitHub
[go: up one dir, main page]

Skip to content

Commit c5e997b

Browse files
loevgaardnicolas-grekas
authored andcommitted
[Cache] Only validate dbindex parameter when applicable
1 parent 672751b commit c5e997b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ private function doTestCreateConnection(string $uri)
6666
$this->assertTrue($redis->isConnected());
6767
$this->assertSame(0, $redis->getDbNum());
6868

69+
$redis = RedisAdapter::createConnection('redis://'.$uri.'/');
70+
$this->assertSame(0, $redis->getDbNum());
71+
6972
$redis = RedisAdapter::createConnection('redis://'.$uri.'/2');
7073
$this->assertSame(2, $redis->getDbNum());
7174

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static function createConnection(string $dsn, array $options = [])
148148
}
149149

150150
if (isset($params['host']) || isset($params['path'])) {
151-
if (!isset($params['dbindex']) && isset($params['path'])) {
151+
if (!isset($params['dbindex']) && isset($params['path']) && '/' !== $params['path']) {
152152
if (preg_match('#/(\d+)$#', $params['path'], $m)) {
153153
$params['dbindex'] = $m[1];
154154
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));

0 commit comments

Comments
 (0)
0