With the rise of autowiring, user provided normalizers must be called before API Platform ones. It's currently not the case, and you have to set a custom priority, it hurts DX.
Current priorities:
Related: #2315
There's also #1815 that can be related, but it's not only normalizers.
Not a bug.
Changing priorities is a BC break, isn't it?
It is. For 3.0?
Upgrading Symfony to 4.2.2 changes the order of the dataproviders and can break an application.
providers in ChainCollectionDataProvider on Symfony 4.2.2
providers in ChainCollectionDataProvider on Symfony 4.2.1
This means that the only way to use a custom Provider is to manually define it in services.yaml with a priority > 0
@wimme002 thanks for your note - I actually ran in exactly this issue ;).
This "non-bug" is affecting many users... Maybe should we do something before 3.0, even if it's a potential BC break, it will be more reliable and less confusing.
I think it is worth it
This seems related to https://github.com/symfony/symfony/issues/29836
With 4.2.2 or 3.4.21 it's a big mess. As @deguif said, there is a new issue with tagged service.
When I added a priority on the tag of APIP service, everything was fine.
But, if it's not a bug...
Couldn't you just give the API Platform normalizers a negative priority? That way they would end up at the end, as the default priority is 0?
It's not a "bug" because these priorities have been defined before the introduction of autoconfiguration in Symfony. However now that it's broadly used, it's very annoying.
The only issue with changing this, it's that's a BC break that will definitely affect existing users. Anyway, this bug in Symfony is maybe the opportunity to move forward?
@apfelbox negative priorities would indeed be the best solution! PRs welcome guys :)
hey, having the same problem.. do you have any example how to change the priority?
I tried the default stuff in services.yaml..
` ############################################
# EVENT LISTENERS + SUBSCRIBERS
############################################
# we need to overwrite the blamable listener definition in order to adjust its priority
# the default priority is 0 and thus it does not add the updatedBy before creating a logEntry
stof_doctrine_extensions.event_listener.blame:
class: "%stof_doctrine_extensions.event_listener.blame.class%"
arguments:
- "@stof_doctrine_extensions.listener.blameable"
- "@security.token_storage"
- "@security.authorization_checker"
tags:
- { name: kernel.event_subscriber, priority: -1 }
`
I'm not using a special listener or subscriber, just the default stuff. this code above has been commented out, I just removed the comments and changed the priority from 10 to -1 ..
no difference, the error still occures..
Thanks,
Julia
hmm but I just saw, that the PR has been reverted and already merged to symfony 3.4
waiting for 4.2 ;)
https://github.com/symfony/symfony/pull/29853
@juhulee I am not a user of the API platform myself, but if I understand it correctly your own listener needs to be added before the core listeners. So you need to use a priority larger than zero.
That's done in 2.4, changes have been logged in the changelog!
Most helpful comment
This "non-bug" is affecting many users... Maybe should we do something before 3.0, even if it's a potential BC break, it will be more reliable and less confusing.