10000 bug #24758 Throwing exception if redis and predis unavailable (aequasi) · symfony/symfony@ca10f8e · GitHub
[go: up one dir, main page]

Skip to content

Commit ca10f8e

Browse files
committed
bug #24758 Throwing exception if redis and predis unavailable (aequasi)
This PR was squashed before being merged into the 3.3 branch (closes #24758). Discussion ---------- Throwing exception if redis and predis unavailable If the redis extension and predis are unavailable, line 137 throws an exception stating that \Predis\Client is not a class. | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none If the redis extension and predis are unavailable, the new line 137 throws an exception stating that \Predis\Client is not a class. Commits ------- e664c81 Throwing exception if redis and predis unavailable
2 parents 7031b61 + e664c81 commit ca10f8e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Predis\Connection\Aggregate\PredisCluster;
1717
use Predis\Connection\Aggregate\RedisCluster;
1818
use Predis\Response\Status;
19+
use Symfony\Component\Cache\Exception\CacheException;
1920
use Symfony\Component\Cache\Exception\InvalidArgumentException;
2021

2122
/**
@@ -108,6 +109,9 @@ public static function createConnection($dsn, array $options = array())
108109
$params += $query;
109110
}
110111
$params += $options + self::$defaultConnectionOptions;
112+
if (null === $params['class'] && !extension_loaded('redis') && !class_exists(\Predis\Client::class)) {
113+
throw new CacheException(sprintf('Cannot find the "redis" extension, and "predis/predis" is not installed: %s', $dsn));
114+
}
111115
$class = null === $params['class'] ? (extension_loaded('redis') ? \Redis::class : \Predis\Client::class) : $params['class'];
112116
113117
if (is_a($class, \Redis::class, true)) {

0 commit comments

Comments
 (0)
0