From d903dcbac565bde4598b29dc445e74401c533f88 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 27 Nov 2018 11:41:07 +1300 Subject: [PATCH 1/4] [Form] Handle all case variants of "nan" when parsing a number Fixes #29321 --- .../Core/DataTransformer/NumberToLocalizedStringTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 9e03606a3e..3e125bc82b 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -146,7 +146,7 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface return; } - if ('NaN' === $value) { + if (\in_array($value, array('NaN', 'NAN', 'nan'), true)) { throw new TransformationFailedException('"NaN" is not a valid number'); } From 85af682834a56ff0b7775d4dd1078b748db0cf52 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 28 Nov 2018 11:07:27 +0100 Subject: [PATCH 2/4] add a test case --- .../NumberToLocalizedStringTransformerTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index d6a4662102..176d3a9a58 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -514,24 +514,24 @@ class NumberToLocalizedStringTransformerTest extends TestCase /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException + * @dataProvider nanRepresentationProvider * * @see https://github.com/symfony/symfony/issues/3161 */ - public function testReverseTransformDisallowsNaN() + public function testReverseTransformDisallowsNaN($nan) { $transformer = new NumberToLocalizedStringTransformer(); - $transformer->reverseTransform('NaN'); + $transformer->reverseTransform($nan); } - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsNaN2() + public function nanRepresentationProvider() { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('nan'); + return array( + array('nan'), + array('NaN'), // see https://github.com/symfony/symfony/issues/3161 + array('NAN'), + ); } /** From 3cd4477563f6f56760c03a6864e38f5328534c19 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 28 Nov 2018 16:00:13 +0100 Subject: [PATCH 3/4] [Messenger] Mention HandleTrait in UPGRADE-4.2.md file --- UPGRADE-4.2.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index bdf2ab0cec..a2fadabc95 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -199,7 +199,10 @@ Messenger --------- * The `MiddlewareInterface::handle()` and `SenderInterface::send()` methods must now return an `Envelope` instance. - * The return value of handlers is ignored. If you used to return a value, e.g in query bus handlers, you can either: + * The return value of handlers isn't forwarded anymore by middleware and buses. + If you used to return a value, e.g in query bus handlers, you can either: + - get the result from the `HandledStamp` in the envelope returned by the bus. + - use the `HandleTrait` to leverage a message bus, expecting a single, synchronous message handling and returning its result. - make your `Query` mutable to allow setting & getting a result: ```php // When dispatching: @@ -209,15 +212,6 @@ Messenger // In your handler: $query->setResult($yourResult); ``` - - define a callable on your `Query` to be called in your handler: - ```php - // When dispatching: - $bus->dispatch(new Query([$this, 'onResult'])); - - // In your handler: - $query->executeCallback($yourResult); - ``` - * The `EnvelopeAwareInterface` was removed and the `MiddlewareInterface::handle()` method now requires an `Envelope` object as first argument. When using built-in middleware with the provided `MessageBus`, you will not have to do anything. If you use your own `MessageBusInterface` implementation, you must wrap the message in an `Envelope` before passing it to middleware. From 977a007e3ac99224564dfeead8ec4d32270bc885 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 29 Nov 2018 09:33:43 +0100 Subject: [PATCH 4/4] typo --- .../Component/Validator/Context/ExecutionContextInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php index 544c82f6c0..e4f7df1757 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php @@ -112,7 +112,7 @@ interface ExecutionContextInterface * Returns the currently validated object. * * If the validator is currently validating a class constraint, the - * object of that class is returned. If it is a validating a property or + * object of that class is returned. If it is validating a property or * getter constraint, the object that the property/getter belongs to is * returned. *