Skip to content

RedisTrait is incompatible with PhpRedis 6.0 when using RedisSentinel and a DSN #51678

@Qonstrukt

Description

@Qonstrukt

Symfony version(s) affected

6.3.x

Description

Version 6.0 of PhpRedis (ext-redis) got released a little over a week ago, and unfortunately the API of RedisSentinel changed such that it's no longer compatible with the way it's being constructed from Symfony\Component\Cache\Traits\RedisTrait when using a DSN.
This will throw errors like:

{
 "class": "ArgumentCountError",
 "message": "RedisSentinel::__construct() expects at most 1 argument, 6 given",
 "code": 0,
 "file": "/var/www/html/vendor/symfony/cache/Traits/RedisTrait.php:228",
 "trace": [
  "/var/www/html/vendor/symfony/cache/Traits/RedisTrait.php:228",
  "/var/www/html/vendor/symfony/cache/Traits/Redis6Proxy.php:656",
  "/var/www/html/vendor/symfony/cache/Traits/RedisTrait.php:400",
  "/var/www/html/vendor/symfony/cache/Traits/AbstractAdapterTrait.php:195",
  "/var/www/html/vendor/symfony/cache-contracts/CacheTrait.php:44",
  "/var/www/html/vendor/symfony/cache/Traits/ContractsTrait.php:85",
  "/var/www/html/vendor/symfony/cache-contracts/CacheTrait.php:30",
  "/var/www/html/src/Momo/Application/Health/Controller/HealthController.php:28",
  "/var/www/html/vendor/symfony/http-kernel/HttpKernel.php:182",
  "/var/www/html/vendor/symfony/http-kernel/HttpKernel.php:76",
  "/var/www/html/vendor/symfony/http-kernel/Kernel.php:197",
  "/var/www/html/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35",
  "/var/www/html/vendor/autoload_runtime.php:29",
  "/var/www/html/public/index.php:5"
 ]
}

The constructor of RedisSentinel is now synchronised with the one used in the Redis class:
phpredis/phpredis@ebb2386e

Perhaps there are more compatibility issues, but we haven't run into them with just a single Redis Node, without sentinel on our dev environment.

How to reproduce

Using a DSN like this causes problems:

parameters:
    redis_service: 'my-redis-service'
    redis_domain:  '%redis_service%-headless.redis.svc.cluster.local'
    redis_port:    26379
    redis_db:      0
    redis_dsn: >-
        redis:?
        host[%redis_service%-node-0.%redis_domain%:%redis_port%]&
        host[%redis_service%-node-1.%redis_domain%:%redis_port%]&
        host[%redis_service%-node-2.%redis_domain%:%redis_port%]&
        redis_sentinel=mymaster&
        dbindex=%redis_db%

framework:
    cache:
        default_redis_provider: '%redis_dsn%'

Possible Solution

Support the new single parameter constructor for at least RedisSentinel, which is now synchronised with the Redis class implementation.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy