Skip to content

[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

Merged
merged 1 commit into from
Apr 19, 2016

Conversation

tgalopin
Copy link
Contributor

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:

#framework:
#    serializer:
#        cache: serializer.mapping.cache.doctrine.apc

@nicolas-grekas
Copy link
Member

👍

@dunglas
Copy link
Member

dunglas commented Apr 19, 2016

👍

@nicolas-grekas
Copy link
Member

Thank you @tgalopin.

@nicolas-grekas nicolas-grekas merged commit 4f0b8be into symfony:master Apr 19, 2016
nicolas-grekas added a commit that referenced this pull request Apr 19, 2016
…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')) {
Copy link
Member

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?

Copy link
Member

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

nicolas-grekas added a commit that referenced this pull request Apr 27, 2016
…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"
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Apr 27, 2016
…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"
@fabpot fabpot mentioned this pull request May 13, 2016
@tgalopin tgalopin deleted the serializer-default-cache branch July 29, 2016 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants