Skip to content

[Cache] RedisTrait::createConnection does not pass auth value from redis sentinel cluster DSN #48712

@evgkord

Description

@evgkord

Symfony version(s) affected

5.4

Description

When redis sentinel cluster with non-empty auth phrase used, we may pass it in DSN as described. However, param "auth" stay ignored and not passes properly while RedisTrait::createConnection.

How to reproduce

  1. Ensure the redis php extension is installed
  2. Create a redis connection with multiple sentinel hosts and non-empty auth phrase: RedisAdapter::createConnection('redis:?host[sentinel1:26379]&host[sentinel2:26379]&host[sentinel3:26379]&redis_sentinel=mysentinel&auth=myauth')

Expected Behaviour
An instance of \Redis should be returned with a connection to the current redis master assigned by redis sentinel

Current Behaviour
After \RedisSentinel instance created without auth phrase, calling method ::getMasterAddrByName() is unable to get adress of master in cluster and it causes \Symfony\Component\Cache\Exception\InvalidArgumentException with message 'Failed to retrieve master information from sentinel "mysentinel" and dsn "redis:?host[sentinel1:26379]&host[sentinel2:26379]&host[sentinel3:26379]&redis_sentinel=mysentinel&auth=myauth".'

Possible Solution

phpredis extension supports passing auth as argument of \RedisSentinel::__consruct(), so it probably should be passed if it present in DSN.

also param auth should be passed in such trait while \Redis::connect(), as described to avoid RedisException: NOAUTH Authentication required, for example when you later want some $redis->eval(...),

Additional Context

PR 48711

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

      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