Closed
Description
Symfony version(s) affected: 5.3.7, 5.3.8
Description
When the Cache component is configured with a Redis DSN with non-numeric dbindex (eg. redis://redis/foo
rather than redis://redis/1
), the dbindex is silently ignored.
How to reproduce
<?php
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;
return static function (FrameworkConfig $framework) {
$cache = $framework->cache();
$cache->app('cache.adapter.redis')
->defaultRedisProvider('redis://redis/foo');
$cache->pool('my_pool.cache')->adapters(['cache.app']);
};
Then start using the cache. Default dbindex 0
will be used.
Possible Solution
Fail or at least log if the DSN contains a dbindex which is not numeric.
Additional context
This line seems to be related:
if (!isset($params['dbindex']) && isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
…
This condition checks if the dbindex is present (isset($params['path'])
) and numeric (preg_match(…)
). There's no handling for a present but invalid dbindex.