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

[FrameworkBundle][Serializer] Fix a deprecation triggered by the ClassMetadataFactory#18630

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 3 commits intosymfony:masterfromGuilhemN:SERIALIZER
Apr 27, 2016

Conversation

@GuilhemN
Copy link
Contributor

@GuilhemNGuilhemN commentedApr 24, 2016
edited
Loading

QA
Branch?master
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets
LicenseMIT

Without apparent reasons,FOSRestBundle's tests fail 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 indebug 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 classCacheClassMetadataFactory, otherwise the second parameter of theClassMetadataFactory is used).

@GuilhemN
Copy link
ContributorAuthor

The tests failure seems unrelated.

->children()
->booleanNode('enable_annotations')->defaultFalse()->end()
->scalarNode('cache')->defaultValue('serializer.mapping.cache.symfony')->end()
->scalarNode('cache')->defaultValue('cache.pool.serializer')->end()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this is a BC break to me, isn't it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If this is merged in 3.1 where it was introduced, then I think it isn't.

@javiereguiluz
Copy link
Member

@Ener-Getick please, don't remove any of the rows of the PR table. In your table we miss theBranch row, which is were you propose where to merge this. If you are not sure, it's OK to say so. Thanks!

@GuilhemN
Copy link
ContributorAuthor

@javiereguiluz I thought it was enough to target the right branch, added ☺

{
public function process(ContainerBuilder $container)
{
if (!$container->hasAlias('serializer.mapping.cache') && !$container->hasDefinition('serializer.mapping.cache')) {
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 just use$container->has('serializer.mapping.cache').

@xabbuh
Copy link
Member

Can't we always use theCacheClassMetadataFactory when the cache is configured and optionally wrap a Doctrine cache instance in aDoctrineAdapter?

@nicolas-grekas
Copy link
Member

Understood, this is for 3.1 :)
Then I have a few suggestions:

  • change the deprecation message to add the version: ...constructor is deprecatedsince version 3.1....
  • replace the compiler pass by a deprecation of the cache configuration key and a few wiring in the DI extension.

@nicolas-grekas
Copy link
Member

If we don't want to deprecate the cache configuration key, then I'd suggest doing what@xabbuh suggests, and do it at runtime using a static method as factory added toCacheClassMetadataFactory, tagged@internal

@xabbuh
Copy link
Member

I agree with@nicolas-grekas. Now that we have thecache.pool.serializer pool we do not need thecache config option for the serializer anymore. People can now configure the cache through the semantic config of the cache subsystem.

@GuilhemN
Copy link
ContributorAuthor

GuilhemN commentedApr 25, 2016
edited
Loading

@nicolas-grekas@xabbuh then the default value introduced in#18561 should be removed right ?

@GuilhemNGuilhemN changed the title[Serializer] Fix a deprecation triggered by the ClassMetadataFactory[FrameworkBundle][Serializer] Fix a deprecation triggered by the ClassMetadataFactoryApr 25, 2016
@nicolas-grekas
Copy link
Member

Yep, can you do that in this PR, as a first commit?

@GuilhemN
Copy link
ContributorAuthor

@nicolas-grekas yes, I'm gonna split my commit


if (!$container->getParameter('kernel.debug')) {
if (isset($config['cache']) &&$config['cache']) {
@trigger_error('Using the option "framework.serializer.cache" is deprecated since version 3.1. This option will be removed in 4.0. You can configure a cache pool called "serializer" under "framework.cache" instead.',E_USER_DEPRECATED);
Copy link
Member

@nicolas-grekasnicolas-grekasApr 25, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What about:
The "framework.serializer.cache" option is deprecated since Symfony 3.1 and will be removed in 4.0. You can configure a cache pool called "serializer" under "framework.cache.pools" instead.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM 👍

@GuilhemNGuilhemNforce-pushed theSERIALIZER branch 2 times, most recently from205f808 to0d7ecc7CompareApril 25, 2016 17:25
@GuilhemNGuilhemNforce-pushed theSERIALIZER branch 5 times, most recently from60d94c6 tof44cb14CompareApril 25, 2016 17:51
@GuilhemN
Copy link
ContributorAuthor

GuilhemN commentedApr 25, 2016
edited
Loading

Rebased and updated.

I also added notes in the upgrading files to inform about this new deprecation.

$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
}

publicfunctiontestDeprecatedSerializerCacheOption()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should be tagged@group legacy so that we don't forget removing it when preparing 4.0

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

done

@@ -0,0 +1,8 @@
<?php

$container->loadFromExtension('framework', array(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I suggest adding the "legacy" word in these fixtures so we can easily find them when preparing 4.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I mean in the filename

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍, renamed toserializer_legacy_cache

@nicolas-grekas
Copy link
Member

👍 with only one wonder: should the UPGRADE files tell about the serializer pool, and/or tell aboutcache.pool.local, which is the centralized way of configuring e.g. APCu for all internal adapters at once?

@GuilhemN
Copy link
ContributorAuthor

I didn't think aboutcache.pool.local, this is indeed probably better to use it.
And in case the user wants something more specific, we can add a link to the documentation (which doesn't exist yet).

```yaml
framework:
serializer:~

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this level should be removed,cache is a direct child offramework

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

no it should not be removed. If you remove theserializer key entirely, it disables the serializer in FrameworkBundle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@nicolas-grekas
Copy link
Member

Thank you @Ener-Getick.

@nicolas-grekasnicolas-grekas merged commit15579d5 intosymfony:masterApr 27, 2016
nicolas-grekas added a commit that referenced this pull requestApr 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       | MITWithout 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.cacheeccbffb [Serializer] Improve a deprecation message96e418a Revert "[FrameworkBundle] Fallback to default cache system in production for serializer"
@GuilhemNGuilhemN deleted the SERIALIZER branchApril 27, 2016 12:52
fabpot added a commit that referenced this pull requestApr 28, 2016
… regressions (Ener-Getick)This PR was merged into the 3.1-dev branch.Discussion----------[FrameworkBundle] Fix a typo and add a test to prevent new regressions| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |This fixes a typo introduced in#18630 and adds a new functional test to avoid most regressions in service definitions in the future when features are only available in non-debug mode.cc@nicolas-grekasCommits-------61872ce Fix a typo and add a check to prevent regressions
fabpot added a commit to symfony/symfony-standard that referenced this pull requestMay 9, 2016
…r-Getick)This PR was merged into the 3.1-dev branch.Discussion----------Do not use validator.cache and serializer.cache anymore``framework.serializer.cache`` has been deprecated insymfony/symfony#18630 in favor of the new caching system.seesymfony/symfony#18630Commits-------e7a2085 Use the new cache system configuration
@fabpotfabpot mentioned this pull requestMay 13, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@GuilhemN@javiereguiluz@xabbuh@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp