Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DX] bin/console debug:container --tag serializer.normalizer not sorted by priority even though it's very relevent #45396

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

Closed
dkarlovi opened this issue Feb 11, 2022 · 2 comments
Labels
Bug DX DX = Developer eXperience (anything that improves the experience of using Symfony) Good first issue Ideal for your first contribution! (some Symfony experience may be required) Status: Needs Review

Comments

@dkarlovi
Copy link
Contributor

Symfony version(s) affected

5.4

Description

When debugging the serializer, the order of normalizers is very important. The configuration takes the priority attribute into account when injecting them.

But, the priority is not used to sort the debug info here, meaning you can't read the list top to bottom and understand the normalizers order used. This is a DX bug.

How to reproduce

Run

$ bin/console debug:container --tag serializer.normalizer

  serializer.normalizer.constraint_violation_list   -915       Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer  
  serializer.normalizer.datetimezone                -915       Symfony\Component\Serializer\Normalizer\DateTimeZoneNormalizer             
  serializer.normalizer.dateinterval                -915       Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer             
  serializer.normalizer.data_uri                    -920       Symfony\Component\Serializer\Normalizer\DataUriNormalizer                  
  serializer.normalizer.datetime                    -910       Symfony\Component\Serializer\Normalizer\DateTimeNormalizer                 
  serializer.normalizer.json_serializable           -900       Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer         
  serializer.normalizer.problem                     -890       Symfony\Component\Serializer\Normalizer\ProblemNormalizer                  
  serializer.normalizer.uid                         -890       Symfony\Component\Serializer\Normalizer\UidNormalizer                      
  serializer.normalizer.form_error                  -915       Symfony\Component\Serializer\Normalizer\FormErrorNormalizer                
  serializer.normalizer.object                      -1000      Symfony\Component\Serializer\Normalizer\ObjectNormalizer                   
  serializer.denormalizer.array                     -990       Symfony\Component\Serializer\Normalizer\ArrayDenormalizer     

Possible Solution

Sort the --tags list by priority by default. Not sure if only for specific tags, but it should reflect the order the container will find the services in.

Additional Context

No response

@dkarlovi dkarlovi added the Bug label Feb 11, 2022
@carsonbot carsonbot added DX DX = Developer eXperience (anything that improves the experience of using Symfony) Status: Needs Review labels Feb 11, 2022
@javiereguiluz javiereguiluz added the Good first issue Ideal for your first contribution! (some Symfony experience may be required) label Feb 11, 2022
@javiereguiluz
Copy link
Member

Seems like a good idea. I've added the good first issue tag in case someone wants to give this a try. Thanks!

@Ahummeling
Copy link
Contributor

Ahummeling commented Feb 11, 2022

I think I found out what went wrong here and I've submitted a PR :) #45399

nicolas-grekas added a commit that referenced this issue Feb 11, 2022
…vices by priority (Ahummeling)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Fix sorting bug in sorting of tagged services by priority

Fixed incorrect assumption that the minimum priority is zero
leading to an unsorted list of negative priorities.

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #45396
| License       | MIT
| Doc PR        |

Fixed an incorrect assumption that the minimum priority is zero which was leading to an unsorted list of negative priorities.
(See #45396)

Commits
-------

9b5c564 fix sorting bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug DX DX = Developer eXperience (anything that improves the experience of using Symfony) Good first issue Ideal for your first contribution! (some Symfony experience may be required) Status: Needs Review
Projects
None yet
Development

No branches or pull requests

5 participants