Skip to content

Commit

Permalink
bug #23045 [Cache] fix Redis scheme detection (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.2 branch.

Discussion
----------

[Cache] fix Redis scheme detection

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22974
| License       | MIT
| Doc PR        |

Commits
-------

61685c7 [Cache] fix Redis scheme detection
  • Loading branch information
nicolas-grekas committed Jun 3, 2017
2 parents 3e92637 + 61685c7 commit 7078cdf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Symfony/Component/Cache/Adapter/RedisAdapter.php
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 7078cdf

Please sign in to comment.