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

Most upvoted comments

@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 with redis://localhost:6379 -> no ending slash) was OK in 5.3.10

Invalid Redis DSN: "redis://localhost:6379/", the "dbindex" parameter must be a number.