Skip to content

Commit

Permalink
bug #34967 [HttpFoundation] fix redis multi host dsn not recognized (…
Browse files Browse the repository at this point in the history
…Jan Christoph Beyer)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpFoundation] fix redis multi host dsn not recognized

| Q             | A
| ------------- | ---
| Branch?       |  4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34477
| License       | MIT

#34177 added support configurating session handlers with DSNs. It was no possible to pass a redis-DSN like
`redis:?host[localhost]&host[localhost:6379]&host[/var/run/redis.sock:]&auth=my-password&redis_cluster=1'`

since the check was
`case 0 === strpos($connection, 'redis://'):`

Commits
-------

81ba07a fix redis multi host dsn not recognized
  • Loading branch information
nicolas-grekas committed Dec 13, 2019
2 parents 0636177 + 81ba07a commit 212dc53
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -50,13 +50,13 @@ public static function createHandler($connection): AbstractSessionHandler
case 0 === strpos($connection, 'file://'):
return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7)));

case 0 === strpos($connection, 'redis://'):
case 0 === strpos($connection, 'rediss://'):
case 0 === strpos($connection, 'memcached://'):
case 0 === strpos($connection, 'redis:'):
case 0 === strpos($connection, 'rediss:'):
case 0 === strpos($connection, 'memcached:'):
if (!class_exists(AbstractAdapter::class)) {
throw new InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require symfony/cache".', $connection));
}
$handlerClass = 0 === strpos($connection, 'memcached://') ? MemcachedSessionHandler::class : RedisSessionHandler::class;
$handlerClass = 0 === strpos($connection, 'memcached:') ? MemcachedSessionHandler::class : RedisSessionHandler::class;
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);

return new $handlerClass($connection);
Expand Down

0 comments on commit 212dc53

Please sign in to comment.