Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a list to DSN config via env variable is not handled properly #607

Closed
Vorta opened this issue Apr 21, 2021 · 1 comment
Closed

Comments

@Vorta
Copy link

Vorta commented Apr 21, 2021

I was trying to configure SNC Redis Bundle to utilize ENV variables for the list of DSNs, but I've discovered that this case is not properly handled (or it is not intended to be possible?). I have noticed that Snc\RedisBundle\Factory\PhpredisClientFactory does have this case handled properly (line 48). The version I'm using is 3.3.0.

Steps to reproduce:

So, lets say we have the following config:

snc_redis:
    clients:
        default:
            type: phpredis
            alias: default
            dsn:
                - redis://localhost:7000
                - redis://localhost:7001
                - redis://localhost:7002
            options:
                cluster: true

This will work flawlessly. However, if I want to have the same list of DSNs passed in via environment variables, the config would look like:

snc_redis:
    clients:
        default:
            type: phpredis
            alias: default
            dsn: '%env(csv:REDIS_DSN)%'
            options:
                cluster: true

and .env would contain:

REDIS_DSN=redis://localhost:7000,redis://localhost:7001,redis://localhost:7002

In the first case Snc\RedisBundle\Factory\PredisParametersFactory receives $dsn as:

string(22) "redis://localhost:7000"

In the second case it receives:

array(3) {
  [0]=>
  string(22) "redis://localhost:7000"
  [1]=>
  string(22) "redis://localhost:7001"
  [2]=>
  string(22) "redis://localhost:7002"
}

...even though it should be the same.

@ostrolucky
Copy link
Collaborator

Duplicate of #483

@ostrolucky ostrolucky marked this as a duplicate of #483 Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants