Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Invalid dbindex silently ignored in Redis DSN #43359

Copy link
Copy link
Closed
@gronostajo

Description

@gronostajo
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.