Merge branch '4.3' into 4.4

This commit is contained in:
Tobias Schultze 2020-01-29 15:35:06 +01:00
commit 737a3e59a7
5 changed files with 40 additions and 5 deletions

View File

@ -403,6 +403,7 @@ trait PdoTrait
} else { } else {
switch ($this->driver = $this->conn->getDriver()->getName()) { switch ($this->driver = $this->conn->getDriver()->getName()) {
case 'mysqli': case 'mysqli':
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', \get_class($this)));
case 'pdo_mysql': case 'pdo_mysql':
case 'drizzle_pdo_mysql': case 'drizzle_pdo_mysql':
$this->driver = 'mysql'; $this->driver = 'mysql';

View File

@ -317,6 +317,7 @@ class PdoStore implements StoreInterface
} else { } else {
switch ($this->driver = $con->getDriver()->getName()) { switch ($this->driver = $con->getDriver()->getName()) {
case 'mysqli': case 'mysqli':
throw new NotSupportedException(sprintf('The store "%s" does not support the mysqli driver, use pdo_mysql instead.', \get_class($this)));
case 'pdo_mysql': case 'pdo_mysql':
case 'drizzle_pdo_mysql': case 'drizzle_pdo_mysql':
$this->driver = 'mysql'; $this->driver = 'mysql';

View File

@ -207,7 +207,40 @@ class SerializerTest extends TestCase
$encoded = $serializer->encode($envelope); $encoded = $serializer->encode($envelope);
$this->assertStringNotContainsString('DummySymfonySerializerNonSendableStamp', print_r($encoded['headers'], true)); $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 DummySymfonySerializerNonSendableStamp implements NonSendableStampInterface
{ {
} }
class DummySymfonySerializerInvalidConstructor
{
public function __construct(string $missingArgument)
{
}
}

View File

@ -85,13 +85,13 @@ class Connection
// check for extra keys in options // check for extra keys in options
$optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS)); $optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($optionsExtraKeys)) { 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 // check for extra keys in options
$queryExtraKeys = array_diff(array_keys($query), array_keys(self::DEFAULT_OPTIONS)); $queryExtraKeys = array_diff(array_keys($query), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($queryExtraKeys)) { 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; return $configuration;

View File

@ -19,7 +19,7 @@ use Symfony\Component\Messenger\Stamp\SerializerStamp;
use Symfony\Component\Messenger\Stamp\StampInterface; use Symfony\Component\Messenger\Stamp\StampInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder; 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\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer as SymfonySerializer; use Symfony\Component\Serializer\Serializer as SymfonySerializer;
@ -79,7 +79,7 @@ class Serializer implements SerializerInterface
try { try {
$message = $this->serializer->deserialize($encodedEnvelope['body'], $encodedEnvelope['headers']['type'], $this->format, $context); $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); throw new MessageDecodingFailedException(sprintf('Could not decode message: %s.', $e->getMessage()), $e->getCode(), $e);
} }
@ -117,7 +117,7 @@ class Serializer implements SerializerInterface
try { try {
$stamps[] = $this->serializer->deserialize($value, substr($name, \strlen(self::STAMP_HEADER_PREFIX)).'[]', $this->format, $this->context); $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); throw new MessageDecodingFailedException(sprintf('Could not decode stamp: %s.', $e->getMessage()), $e->getCode(), $e);
} }
} }