-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Add FlattenException Normalizer #37087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Messenger] Add FlattenException Normalizer #37087
Conversation
I still need to test well the priority, because it works on my symfony 5.0 (without it), but I want to try it on Symfony 4.4 to see if I have the same behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API platform normalizes FlattenException at a very low prio, is it an issue?
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Tests/Normalizer/FlattenExceptionNormalizerTest.php
Outdated
Show resolved
Hide resolved
I have 2 unit tests failing:
@nicolas-grekas Maybe you can help me with this. I know that on the FlattenException Unit tests you never use the constructor without arguments. You did the change in the past adding typehints to the FlattenException class methods, which makes total sense when you are creating this exception from throwable. But what can we do in this specific case? Should I still use the empty constructor here or should I use reflection? If I use it, makes sense to test the empty constructor but since they have different type hints from the getters (Example: message is null in the empty constructor, but getMessage() has a string typehint) the test fails. Or should I follow the FlattenException unit tests and remove the empty constructor test? Note: This does not happen in this specific feature, because the normalizer does not call any getter without a full FlattenException. |
459b375
to
a5aae27
Compare
a5aae27
to
6c1b966
Compare
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml
Outdated
Show resolved
Hide resolved
6c1b966
to
0981943
Compare
src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the reasoning. That works for me.
src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml
Outdated
Show resolved
Hide resolved
c39cb1b
to
c528a31
Compare
src/Symfony/Component/Serializer/Normalizer/FlattenExceptionNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Tests/Normalizer/FlattenExceptionNormalizerTest.php
Outdated
Show resolved
Hide resolved
Tests need to be updated to pass. |
@fabpot I have updated the tests but some Travis tests are failing with the error that the FlattenExceptionNormalizer class does not exist (FrameworkBundle is fetching v5.0 in Travis). I suppose that will only be green when we merge this or am I missing something? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are broken because of the constraints in composer.json. I will fix it while merging.
c91b71a
to
78fbd0a
Compare
Thank you @monteiro. |
I have just duplicated the PR #33650 (from @skalpa) but using the new component ErrorHandler and removing the priority.
Project that reproduces the bug on Symfony 5.2: https://github.com/monteiro/serializer-pr37087 (all steps are on the README).
Since this adds a new class and changes behavior, we add this new feature on the 5.2 branch.