fix(symfony): keep denormalize on decorated normalizers - #8606
Merged
soyuka merged 3 commits intoSep 29, 2026
Merged
Conversation
Since api-platform#7713 each item normalizer has a dedicated denormalizer registered one priority higher, so a user decorator of the normalizer that also implements DenormalizerInterface was never reached for denormalization. When such a decorator exists, detach the matching denormalizer from the serializer chain and trigger a deprecation pointing to the denormalizer service. Fixes api-platform#8550
In the full suite, earlier kernel boots leave Symfony ErrorHandler registered, which swallows the deprecation before expectUserDeprecationMessage sees it. Capture it with a local error handler, as AttributeFilterPassTest does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#7713 split each item normalizer into a normalizer and an
ItemDenormalizerregistered one priority higher (for exampleapi_platform.jsonld.denormalizer.itemat -889,api_platform.jsonld.normalizer.itemat -890). The documentation told users to add custom denormalization logic by decorating the normalizer. After the split, such a decorator is never reached for denormalization, and nothing warns about it.This adds a BC layer.
ItemNormalizerDecorationBcPasslooks for user decorators ofapi_platform.{serializer,jsonld,jsonapi,graphql}.normalizer.itemthat implementDenormalizerInterface. When it finds one, it removes theserializer.normalizertag from the matching*.denormalizer.itemservice, so denormalization goes through the decorated normalizer again, which is the pre-4.4 behaviour. It also triggers a deprecation that asks users to decorate the denormalizer service instead. Our own decorators (api_platform.*ids, for example Elasticsearch) are ignored, and so are apps that already decorate the denormalizer.The pass stays on 5.0 and main, and goes away in 6.0 together with the deprecated
ItemNormalizer::denormalize().Tests:
ItemNormalizerDecorationBcPassTest: the tag is removed and the deprecation is triggered; a normalize-only decorator, a decorator that already targets the denormalizer, and anapi_platform.*decorator change nothing.DecoratedItemNormalizerDenormalizationTest: a POST through an#[AsDecorator]decorator of the JSON-LD normalizer, with its own kernel. It fails before this change withExpected 'decorated', Actual 'original'.