-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Fallback to default cache system in production for serializer #18561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FrameworkBundle] Fallback to default cache system in production for serializer #18561
Conversation
👍 |
👍 |
Thank you @tgalopin. |
…production for serializer (tgalopin) This PR was merged into the 3.1-dev branch. Discussion ---------- [FrameworkBundle] Fallback to default cache system in production for serializer | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - In the same idea as #18544, this PR proposes a default fallback to filesystem cache for the serializer if the APC cache is not enabled in production. In other words, if the following part of `config_prod.yml` file is not uncommented, the filesystem will be used: ``` yaml #framework: # serializer: # cache: serializer.mapping.cache.doctrine.apc ``` Commits ------- 4f0b8be [FrameworkBundle] Fallback to default cache system in production for serializer
@@ -982,7 +982,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder | |||
|
|||
$chainLoader->replaceArgument(0, $serializerLoaders); | |||
|
|||
if (isset($config['cache']) && $config['cache']) { | |||
if (!$container->getParameter('kernel.debug')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means I can never enable the cache during development. Is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can, you just have to --env=prod
since there is no invalidation, enabling this cache in dev only creates WTFs :-)
We did a similar change for validation:
https://github.com/symfony/symfony/pull/18544/files#diff-0e793081ceb720201745c982a568903fL784
…by the ClassMetadataFactory (Ener-Getick) This PR was merged into the 3.1-dev branch. Discussion ---------- [FrameworkBundle][Serializer] Fix a deprecation triggered by the ClassMetadataFactory | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT Without apparent reasons, [FOSRestBundle's tests fail](https://travis-ci.org/FriendsOfSymfony/FOSRestBundle/jobs/124384888) since #18561. ``` Passing a Doctrine Cache instance as 2nd parameter of the "Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory" constructor is deprecated. This parameter will be removed in Symfony 4.0. Use the "Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory" class instead: 6x 1x in ErrorWithTemplatingFormatTest::testSerializeExceptionHtml from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeExceptionJson from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeExceptionJsonWithoutDebug from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeExceptionXml from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeInvalidFormJson from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeInvalidFormXml from FOS\RestBundle\Tests\Functional ``` We don't use cache in our tests but some of them are not in ``debug`` mode (will change soon) so the cache is automatically used. This PR fixes this deprecation by detecting if the cache used by the serializer is psr6 compliant or not (if it is, then it replaces the default metadata factory by an instance of the new class ``CacheClassMetadataFactory``, otherwise the second parameter of the ``ClassMetadataFactory`` is used). Commits ------- 15579d5 [FrameworkBundle] Deprecate framework.serializer.cache eccbffb [Serializer] Improve a deprecation message 96e418a Revert "[FrameworkBundle] Fallback to default cache system in production for serializer"
…by the ClassMetadataFactory (Ener-Getick) This PR was merged into the 3.1-dev branch. Discussion ---------- [FrameworkBundle][Serializer] Fix a deprecation triggered by the ClassMetadataFactory | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT Without apparent reasons, [FOSRestBundle's tests fail](https://travis-ci.org/FriendsOfSymfony/FOSRestBundle/jobs/124384888) since symfony/symfony#18561. ``` Passing a Doctrine Cache instance as 2nd parameter of the "Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory" constructor is deprecated. This parameter will be removed in Symfony 4.0. Use the "Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory" class instead: 6x 1x in ErrorWithTemplatingFormatTest::testSerializeExceptionHtml from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeExceptionJson from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeExceptionJsonWithoutDebug from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeExceptionXml from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeInvalidFormJson from FOS\RestBundle\Tests\Functional 1x in SerializerErrorTest::testSerializeInvalidFormXml from FOS\RestBundle\Tests\Functional ``` We don't use cache in our tests but some of them are not in ``debug`` mode (will change soon) so the cache is automatically used. This PR fixes this deprecation by detecting if the cache used by the serializer is psr6 compliant or not (if it is, then it replaces the default metadata factory by an instance of the new class ``CacheClassMetadataFactory``, otherwise the second parameter of the ``ClassMetadataFactory`` is used). Commits ------- 15579d5 [FrameworkBundle] Deprecate framework.serializer.cache eccbffb [Serializer] Improve a deprecation message 96e418a Revert "[FrameworkBundle] Fallback to default cache system in production for serializer"
In the same idea as #18544, this PR proposes a default fallback to filesystem cache for the serializer if the APC cache is not enabled in production. In other words, if the following part of
config_prod.yml
file is not uncommented, the filesystem will be used: