Skip to content

Commit

Permalink
bug #54484 [Serializer] reset backed_enum priority, and re-prioritise…
Browse files Browse the repository at this point in the history
… translatable (GwendolenLynch)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Serializer] reset backed_enum priority, and re-prioritise translatable

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #54478 Fix api-platform/core#6285 Fix api-platform/core#6279
| License       | MIT

- `serializer.normalizer.translatable` -920 (was -890)
- `serializer.normalizer.backed_enum` -915 (originally -915, changed to -880)

Floating this as as solution to the knock-on issues from #54478

Context:
- #54478 (comment)
- api-platform/core#6288

Commits
-------

b559aa5 [Serializer] reset backed_enum priority, and re-prioritise translatable
  • Loading branch information
nicolas-grekas committed Apr 4, 2024
2 parents 39d989a + b559aa5 commit 8cf4923
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

->set('serializer.normalizer.translatable', TranslatableNormalizer::class)
->args(['$translator' => service('translator')])
->tag('serializer.normalizer', ['priority' => -890])
->tag('serializer.normalizer', ['priority' => -920])

->set('serializer.normalizer.form_error', FormErrorNormalizer::class)
->tag('serializer.normalizer', ['priority' => -915])
Expand Down Expand Up @@ -219,6 +219,6 @@
])

->set('serializer.normalizer.backed_enum', BackedEnumNormalizer::class)
->tag('serializer.normalizer', ['priority' => -880])
->tag('serializer.normalizer', ['priority' => -915])
;
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer;
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer;
Expand Down Expand Up @@ -1606,10 +1607,24 @@ public function testTranslatableNormalizerRegistered()
$tag = $definition->getTag('serializer.normalizer');

$this->assertSame(TranslatableNormalizer::class, $definition->getClass());
$this->assertSame(-890, $tag[0]['priority']);
$this->assertSame(-920, $tag[0]['priority']);
$this->assertEquals(new Reference('translator'), $definition->getArgument('$translator'));
}

/**
* @see https://github.com/symfony/symfony/issues/54478
*/
public function testBackedEnumNormalizerRegistered()
{
$container = $this->createContainerFromFile('full');

$definition = $container->getDefinition('serializer.normalizer.backed_enum');
$tag = $definition->getTag('serializer.normalizer');

$this->assertSame(BackedEnumNormalizer::class, $definition->getClass());
$this->assertSame(-915, $tag[0]['priority']);
}

public function testSerializerCacheActivated()
{
$container = $this->createContainerFromFile('serializer_enabled');
Expand Down

0 comments on commit 8cf4923

Please sign in to comment.