-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,26 +16,26 @@ Form | |
|
||
* Support for data objects that implements both `Traversable` and | ||
`ArrayAccess` in `ResizeFormListener::preSubmit` method has been removed. | ||
* Using callable strings as choice options in ChoiceType is not supported | ||
|
||
* Using callable strings as choice options in ChoiceType is not supported | ||
anymore in favor of passing PropertyPath instances. | ||
|
||
Before: | ||
|
||
```php | ||
'choice_value' => new PropertyPath('range'), | ||
'choice_label' => 'strtoupper', | ||
``` | ||
|
||
After: | ||
|
||
```php | ||
'choice_value' => 'range', | ||
'choice_label' => function ($choice) { | ||
return strtoupper($choice); | ||
}, | ||
``` | ||
|
||
|
||
FrameworkBundle | ||
--------------- | ||
|
@@ -78,6 +78,28 @@ FrameworkBundle | |
* The service `serializer.mapping.cache.apc` has been removed; use | ||
`serializer.mapping.cache.doctrine.apc` instead. | ||
|
||
* The `framework.serializer.cache` option has been removed. Configure a cache pool | ||
called `serializer` under `framework.cache.pools` instead. | ||
|
||
Before: | ||
|
||
```yaml | ||
framework: | ||
serializer: | ||
cache: serializer.mapping.cache.apc | ||
``` | ||
|
||
After: | ||
|
||
```yaml | ||
framework: | ||
serializer: ~ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be kept as the two code blocks aren't equal otherwise (the serializer is not enabled if this is not present). |
||
cache: | ||
pools: | ||
serializer: | ||
adapter: cache.adapter.apcu | ||
``` | ||
|
||
HttpKernel | ||
---------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
$container->loadFromExtension('framework', array( | ||
'serializer' => array( | ||
'enabled' => true, | ||
'cache' => 'foo', | ||
), | ||
)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:serializer enabled="true" cache="foo"/> | ||
</framework:config> | ||
</container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
framework: | ||
serializer: | ||
enabled: true | ||
cache: foo |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -449,7 +449,7 @@ public function testSerializerEnabled() | |
|
||
$this->assertCount(1, $argument); | ||
$this->assertEquals('Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', $argument[0]->getClass()); | ||
$this->assertEquals(new Reference('serializer.mapping.cache.doctrine.apc'), $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1)); | ||
$this->assertNull($container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1)); | ||
$this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.normalizer.object')->getArgument(1)); | ||
} | ||
|
||
|
@@ -521,6 +521,44 @@ public function testObjectNormalizerRegistered() | |
$this->assertEquals(-1000, $tag[0]['priority']); | ||
} | ||
|
||
public function testSerializerCacheActivated() | ||
{ | ||
$container = $this->createContainerFromFile('serializer_enabled'); | ||
$this->assertTrue($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); | ||
} | ||
|
||
public function testSerializerCacheDisabled() | ||
{ | ||
$container = $this->createContainerFromFile('serializer_enabled', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); | ||
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); | ||
} | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testDeprecatedSerializerCacheOption() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be tagged There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
{ | ||
$deprecations = array(); | ||
set_error_handler(function ($type, $msg) use (&$deprecations) { | ||
if (E_USER_DEPRECATED !== $type) { | ||
restore_error_handler(); | ||
|
||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); | ||
} | ||
|
||
$deprecations[] = $msg; | ||
}); | ||
|
||
$container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); | ||
|
||
restore_error_handler(); | ||
|
||
$this->assertCount(1, $deprecations); | ||
$this->assertContains('The "framework.serializer.cache" option is deprecated', $deprecations[0]); | ||
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); | ||
$this->assertEquals(new Reference('foo'), $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1)); | ||
} | ||
|
||
public function testAssetHelperWhenAssetsAreEnabled() | ||
{ | ||
$container = $this->createContainerFromFile('full'); | ||
|
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 level should be removed,
cache
is a direct child offramework
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.
no it should not be removed. If you remove the
serializer
key entirely, it disables the serializer in FrameworkBundleThere 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.
See https://github.com/symfony/symfony/pull/18648/files