You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding COLLECT_DENORMALIZATION_ERRORS to the framework.default_context has no effect if you want to collect denormalization errors for all ->denormalize calls. It only works, if it is added to each ->denormalize call as an extra argument.
final readonly class Foo
{
public function __construct(
public string $bar,
) {}
}
Denormalize call:
public function __construct(
private DenormalizerInterface $denormalizer,
) {
}
public function __invoke(): void
{
$this->denormalizer->denormalize(
data: [],
type: Foo::class,
);
}
Expected: \Symfony\Component\Serializer\Exception\PartialDenormalizationException is thrown
Actual: \Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException is thrown
Possible Solution
If this is intended behaviour, I would suggest to add this to the documentation here, that it cannot be set as a default.
If this is not an intended behaviour, maybe there is a way to get the context of the used $normalizer at this line in the Serializer Class and use it as another check if it is not set in $context.
Additional Context
No response
The text was updated successfully, but these errors were encountered:
@mtarld sorry for the late reply. Unfortunately, I am pretty busy at the moment, so don't expect a PR in the near future. If anyone else has an idea and time to solve it, feel free :)
This PR was merged into the 6.4 branch.
Discussion
----------
[Serializer] Handle default context in Serializer
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#58628
| License | MIT
This fixes the default context not taken into account by the Serializer class.
Commits
-------
4400674 [Serializer] fix default context in Serializer
Symfony version(s) affected
7.1.*
Description
Adding
COLLECT_DENORMALIZATION_ERRORS
to theframework.default_context
has no effect if you want to collect denormalization errors for all->denormalize
calls. It only works, if it is added to each->denormalize
call as an extra argument.How to reproduce
Framework Config
Object
Denormalize call:
Expected:
\Symfony\Component\Serializer\Exception\PartialDenormalizationException
is thrownActual:
\Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException
is thrownPossible Solution
If this is intended behaviour, I would suggest to add this to the documentation here, that it cannot be set as a default.
If this is not an intended behaviour, maybe there is a way to get the context of the used
$normalizer
at this line in the Serializer Class and use it as another check if it is not set in$context
.Additional Context
No response
The text was updated successfully, but these errors were encountered: