Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  [Debug] fix ClassNotFoundFatalErrorHandler
  [Routing] Fix using a custom matcher & generator dumper class
  [Serializer] Fix cache in MetadataAwareNameConverter
  [Dotenv] Fixed infinite loop with missing quote followed by quoted value
  [HttpClient] Added missing sprintf
  [TwigBridge] button_widget now has its title attr translated even if its label = null or false
  [PhpUnitBridge] When using phpenv + phpenv-composer plugin, composer executable is wrapped into a bash script
  [Messenger] Added check if json_encode succeeded
  [Messenger] Added check if json_encode succeeded
  [FrameworkBundle][ContainerLintCommand] Only skip .errored. services
  [HttpClient] fix exception in case of PSR17 discovery failure
  [DependencyInjection] Handle ServiceClosureArgument for callable in container linting
  fix processing chain adapter based cache pool
  [HttpKernel] release lock explicitly
  [Security] Prevent canceled remember-me cookie from being accepted
  [FrameworkBundle][TranslationUpdateCommand] Do not output positive feedback on stderr
  [Security\Guard] Fix missing typehints
  do not render preferred choices as selected
  • Loading branch information
nicolas-grekas committed Jan 8, 2020
2 parents 2b3be00 + 5eb3bb9 commit b1c7a6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Tests/Transport/RedisExt/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ public function testGetNonBlocking()
$redis->del('messenger-getnonblocking');
}

public function testJsonError()
{
$redis = new \Redis();
$connection = Connection::fromDsn('redis://localhost/json-error', [], $redis);
try {
$connection->add("\xB1\x31", []);
} catch (TransportException $e) {
}

$this->assertSame('Malformed UTF-8 characters, possibly incorrectly encoded', $e->getMessage());
}

public function testMaxEntries()
{
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();
Expand Down
8 changes: 8 additions & 0 deletions Transport/RedisExt/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
'uniqid' => uniqid('', true),
]);

if (false === $message) {
throw new TransportException(json_last_error_msg());
}

$score = (int) ($this->getCurrentTimeInMilliseconds() + $delayInMs);
$added = $this->connection->zadd($this->queue, ['NX'], $score, $message);
} else {
Expand All @@ -256,6 +260,10 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
'headers' => $headers,
]);

if (false === $message) {
throw new TransportException(json_last_error_msg());
}

if ($this->maxEntries) {
$added = $this->connection->xadd($this->stream, '*', ['message' => $message], $this->maxEntries, true);
} else {
Expand Down

0 comments on commit b1c7a6c

Please sign in to comment.