Skip to content

Commit

Permalink
[Cache] fix Redis scheme detection
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jun 3, 2017
1 parent 89c3f5c commit 61685c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Symfony/Component/Cache/Adapter/RedisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public static function createConnection($dsn, array $options = array())
$params['dbindex'] = $m[1];
$params['path'] = substr($params['path'], 0, -strlen($m[0]));
}
if (isset($params['host'])) {
$scheme = 'tcp';
} else {
$scheme = 'unix';
}
$params += array(
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'port' => isset($params['host']) ? 6379 : null,
Expand Down Expand Up @@ -120,7 +125,7 @@ public static function createConnection($dsn, array $options = array())
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e, $dsn));
}
} elseif (is_a($class, \Predis\Client::class, true)) {
$params['scheme'] = isset($params['host']) ? 'tcp' : 'unix';
$params['scheme'] = $scheme;
$params['database'] = $params['dbindex'] ?: null;
$params['password'] = $auth;
$redis = new $class((new Factory())->create($params));
Expand Down

0 comments on commit 61685c7

Please sign in to comment.