10000 Merge branch '4.4' into 5.3 · symfony/cache@5c258c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5c258c0

Browse files
Merge branch '4.4' into 5.3
* 4.4: fix cs Update validators.lv.xlf Update validators.uz.xlf [ExpressionLanguage] Fix LexerTest number types [Process] intersect with getenv() to populate default envs Improve CI script a bit [Cache] fix dbindex Redis Never rely on dynamic properties
2 parents 3421462 + 589395f commit 5c258c0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Tests/Adapter/RedisAdapterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function testInvalidCreateConnection(string $dsn)
112112
public function provideInvalidCreateConnection(): array
113113
{
114114
return [
115+
['redis://localhost/foo'],
115116
['foo://localhost'],
116117
['redis://'],
117118
];

Traits/RedisTrait.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ public static function createConnection(string $dsn, array $options = [])
147147
}
148148

149149
if (isset($params['host']) || isset($params['path'])) {
150-
if (!isset($params['dbindex']) && isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
151-
$params['dbindex'] = $m[1];
152-
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
150+
if (!isset($params['dbindex']) && isset($params['path'])) {
151+
if (preg_match('#/(\d+)$#', $params['path'], $m)) {
152+
$params['dbindex'] = $m[1];
153+
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
154+
} else {
155+
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s", the "dbindex" parameter must be a number.', $dsn));
156+
}
153157
}
154158

155159
if (isset($params['host'])) {

0 commit comments

Comments
 (0)
0