Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4312e96

Browse files
committed
[FrameworkBundle] no serializer mapping cache in debug mode without enable_annotations
There's no reason we should disable the cache only without `enable_annotations`, when working only with attributes, in debug mode the cache is enabled which is why we often need to clear cache when changing a serialized object to get the changes.
1 parent3724f94 commit4312e96

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,14 +1790,15 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
17901790
$container->removeDefinition('serializer.normalizer.mime_message');
17911791
}
17921792

1793+
if ($container->getParameter('kernel.debug')) {
1794+
$container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
1795+
}
1796+
17931797
$serializerLoaders = [];
17941798
if (isset($config['enable_annotations']) &&$config['enable_annotations']) {
17951799
if (\PHP_VERSION_ID <80000 && !$this->annotationsConfigEnabled) {
17961800
thrownew \LogicException('"enable_annotations" on the serializer cannot be set as the PHP version is lower than 8 and Annotations support is disabled. Consider upgrading PHP.');
17971801
}
1798-
if ($container->getParameter('kernel.debug')) {
1799-
$container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
1800-
}
18011802

18021803
$annotationLoader =newDefinition(
18031804
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,12 @@ public function testSerializerCacheActivated()
15301530
publicfunctiontestSerializerCacheUsedWithoutAnnotationsAndMappingFiles()
15311531
{
15321532
$container =$this->createContainerFromFile('serializer_mapping_without_annotations', ['kernel.debug' =>true,'kernel.container_class' =>__CLASS__]);
1533+
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
1534+
}
1535+
1536+
publicfunctiontestSerializerCacheUsedWithoutAnnotationsAndMappingFilesNoDebug()
1537+
{
1538+
$container =$this->createContainerFromFile('serializer_mapping_without_annotations', ['kernel.debug' =>false,'kernel.container_class' =>__CLASS__]);
15331539
$this->assertTrue($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
15341540
}
15351541

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp