symfony: Invalid Redis socket DSN, the "dbindex" parameter must be a number.
Symfony version(s) affected
4.4.34
Description
When the Cache component is configured with a Redis DSN pointing to a socket (eg. redis:///var/run/redis/redis-server.sock), an error is thrown: Invalid Redis DSN: "redis:///var/run/redis/redis-server.sock", the "dbindex" parameter must be a number.
This is probably due to #43359 with fix #44043 and an incorrect preg_match in L151.
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:///var/run/redis/redis-server.sock');
$cache->pool('my_pool.cache')->adapters(['cache.app']);
};
Possible Solution
Skip the preg_match check if $params['host'] is not set?
Additional Context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (17 by maintainers)
Commits related to this issue
- bug #44232 [Cache] fix connecting to local Redis sockets (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [Cache] fix connecting to local Redis sockets | Q ... — committed to symfony/symfony by nicolas-grekas 3 years ago
- bug #49353 [Cache] Only validate dbindex parameter when applicable (loevgaard) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Cache] Only validate dbindex para... — committed to symfony/symfony by nicolas-grekas a year ago
@thomas2411 @mathielen you’re affected by #45277, not by this issue.
@loevgaard do you have more insights about your issue about dbindex, or does #45281 also fix you issue?
We get the error in 5.3.12. Hasn’t this been merged into the 5.3 branch?
5.3.11 broken for
redis://localhost:6379/(OK withredis://localhost:6379-> no ending slash) was OK in 5.3.10