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:
  [Validator] fix access to uninitialized property when getting value
  [HttpClient] Fix regex bearer
  [Translator] Default value for 'sort' option in translation:update should be 'asc'
  [HttpKernel] Fix stale-if-error behavior, add tests
  [Intl] Provide more locale translations
  [Mailer] Fix STARTTLS support for Postmark and Mandrill
  [Messenger] Check for all serialization exceptions during message dec…
  [Messenger] Fix bug when using single route with XML config
  Fix exception message in Doctrine Messenger
  [DI]  CheckTypeDeclarationsPass now checks if value is type of parameter type
  [SecurityBundle] fix security.authentication.provider.ldap_bind arguments
  Improved error message when no supported user provider is found
  Mysqli doesn't support the named parameters used by PdoAdapter
  Added debug argument to decide if debug page should be shown or not
  Mysqli doesn't support the named parameters used by PdoStore
  Properly handle phpunit arguments for configuration file
  [Mailer] add tests for http transports
  • Loading branch information
nicolas-grekas committed Jan 31, 2020
2 parents 518cd67 + caad29e commit 41f762b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
33 changes: 33 additions & 0 deletions Tests/Transport/Serialization/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,40 @@ public function testEncodedSkipsNonEncodeableStamps()
$encoded = $serializer->encode($envelope);
$this->assertStringNotContainsString('DummySymfonySerializerNonSendableStamp', print_r($encoded['headers'], true));
}

public function testDecodingFailedConstructorDeserialization()
{
$serializer = new Serializer();

$this->expectException(MessageDecodingFailedException::class);

$serializer->decode([
'body' => '{}',
'headers' => ['type' => DummySymfonySerializerInvalidConstructor::class],
]);
}

public function testDecodingStampFailedDeserialization()
{
$serializer = new Serializer();

$this->expectException(MessageDecodingFailedException::class);

$serializer->decode([
'body' => '{"message":"hello"}',
'headers' => [
'type' => DummyMessage::class,
'X-Message-Stamp-'.SerializerStamp::class => '[{}]',
],
]);
}
}
class DummySymfonySerializerNonSendableStamp implements NonSendableStampInterface
{
}
class DummySymfonySerializerInvalidConstructor
{
public function __construct(string $missingArgument)
{
}
}
4 changes: 2 additions & 2 deletions Transport/Doctrine/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public static function buildConfiguration(string $dsn, array $options = []): arr
// check for extra keys in options
$optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($optionsExtraKeys)) {
throw new InvalidArgumentException(sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
throw new InvalidArgumentException(sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS))));
}

// check for extra keys in options
$queryExtraKeys = array_diff(array_keys($query), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($queryExtraKeys)) {
throw new InvalidArgumentException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
throw new InvalidArgumentException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS))));
}

return $configuration;
Expand Down
6 changes: 3 additions & 3 deletions Transport/Serialization/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\Messenger\Stamp\StampInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer as SymfonySerializer;
Expand Down Expand Up @@ -79,7 +79,7 @@ public function decode(array $encodedEnvelope): Envelope

try {
$message = $this->serializer->deserialize($encodedEnvelope['body'], $encodedEnvelope['headers']['type'], $this->format, $context);
} catch (UnexpectedValueException $e) {
} catch (ExceptionInterface $e) {
throw new MessageDecodingFailedException(sprintf('Could not decode message: %s.', $e->getMessage()), $e->getCode(), $e);
}

Expand Down Expand Up @@ -117,7 +117,7 @@ private function decodeStamps(array $encodedEnvelope): array

try {
$stamps[] = $this->serializer->deserialize($value, substr($name, \strlen(self::STAMP_HEADER_PREFIX)).'[]', $this->format, $this->context);
} catch (UnexpectedValueException $e) {
} catch (ExceptionInterface $e) {
throw new MessageDecodingFailedException(sprintf('Could not decode stamp: %s.', $e->getMessage()), $e->getCode(), $e);
}
}
Expand Down

0 comments on commit 41f762b

Please sign in to comment.