Skip to content

Commit

Permalink
bug #31872 [Messenger] Add missing runtime check for ext redis versio…
Browse files Browse the repository at this point in the history
…n (chalasr)

This PR was merged into the 4.3 branch.

Discussion
----------

[Messenger] Add missing runtime check for ext redis version

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31791
| License       | MIT
| Doc PR        | n/a

Lower versions lead to segmentation faults.

Commits
-------

07603da [Messenger] Add runtime check for ext redis version
  • Loading branch information
fabpot committed Jun 5, 2019
2 parents e901494 + 07603da commit a6b306d
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Messenger\Transport\RedisExt;

use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\Exception\LogicException;
use Symfony\Component\Messenger\Exception\TransportException;

/**
Expand Down Expand Up @@ -43,6 +44,10 @@ class Connection

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->connect($connectionCredentials['host'] ?? '127.0.0.1', $connectionCredentials['port'] ?? 6379);
$this->connection->setOption(\Redis::OPT_SERIALIZER, $redisOptions['serializer'] ?? \Redis::SERIALIZER_PHP);
Expand Down

0 comments on commit a6b306d

Please sign in to comment.