[Messenger] Add runtime check for ext redis version
This commit is contained in:
parent
28fbf160ae
commit
07603da06c
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Messenger\Transport\RedisExt;
|
namespace Symfony\Component\Messenger\Transport\RedisExt;
|
||||||
|
|
||||||
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
|
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
|
||||||
|
use Symfony\Component\Messenger\Exception\LogicException;
|
||||||
use Symfony\Component\Messenger\Exception\TransportException;
|
use Symfony\Component\Messenger\Exception\TransportException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,6 +44,10 @@ class Connection
|
|||||||
|
|
||||||
public function __construct(array $configuration, array $connectionCredentials = [], array $redisOptions = [], \Redis $redis = null)
|
public function __construct(array $configuration, array $connectionCredentials = [], array $redisOptions = [], \Redis $redis = null)
|
||||||
{
|
{
|
||||||
|
if (version_compare(phpversion('redis'), '4.3.0', '<')) {
|
||||||
|
throw new LogicException('The redis transport requires php-redis 4.3.0 or higher.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->connection = $redis ?: new \Redis();
|
$this->connection = $redis ?: new \Redis();
|
||||||
$this->connection->connect($connectionCredentials['host'] ?? '127.0.0.1', $connectionCredentials['port'] ?? 6379);
|
$this->connection->connect($connectionCredentials['host'] ?? '127.0.0.1', $connectionCredentials['port'] ?? 6379);
|
||||||
$this->connection->setOption(\Redis::OPT_SERIALIZER, $redisOptions['serializer'] ?? \Redis::SERIALIZER_PHP);
|
$this->connection->setOption(\Redis::OPT_SERIALIZER, $redisOptions['serializer'] ?? \Redis::SERIALIZER_PHP);
|
||||||
|
Reference in New Issue
Block a user