bug #16822 [FrameworkBundle][Validator] Fix apc cache service deprecation (ogizanagi)

This PR was merged into the 2.8 branch.

Discussion
----------

[FrameworkBundle][Validator] Fix apc cache service deprecation

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Related to #16795

I guess the deprecation was on the wrong service.
Also, no deprecation notice was triggered about using `"apc"` as the value of the `framework.validation.cache` configuration option. This PR adds the missing deprecation.

> 📝 _NOTE_: The standard edition will need to be updated [here](https://github.com/symfony/symfony-standard/blob/2.8/app/config/config_prod.yml#L6).

Commits
-------

907bbec [FrameworkBundle][Validator] Fix apc cache service deprecation
This commit is contained in:
Fabien Potencier 2016-01-21 08:28:13 +01:00
commit 0c28d753e2
8 changed files with 57 additions and 6 deletions

View File

@ -506,6 +506,28 @@ FrameworkBundle
cookie_httponly: false cookie_httponly: false
``` ```
* The `validator.mapping.cache.apc` service is deprecated, and will be removed in 3.0.
Use `validator.mapping.cache.doctrine.apc` instead.
* The ability to pass `apc` as the `framework.validation.cache` configuration key value is deprecated,
and will be removed in 3.0. Use `validator.mapping.cache.doctrine.apc` instead:
Before:
```yaml
framework:
validation:
cache: apc
```
After:
```yaml
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
```
Security Security
-------- --------

View File

@ -744,6 +744,27 @@ UPGRADE FROM 2.x to 3.0
interface. interface.
The `security.csrf.token_manager` should be used instead. The `security.csrf.token_manager` should be used instead.
* The `validator.mapping.cache.apc` service has been removed in favor of the `validator.mapping.cache.doctrine.apc` one.
* The ability to pass `apc` as the `framework.validation.cache` configuration key value has been removed.
Use `validator.mapping.cache.doctrine.apc` instead:
Before:
```yaml
framework:
validation:
cache: apc
```
After:
```yaml
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
```
### HttpKernel ### HttpKernel
* The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in * The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in

View File

@ -645,7 +645,15 @@ class Configuration implements ConfigurationInterface
->scalarNode('cache') ->scalarNode('cache')
->beforeNormalization() ->beforeNormalization()
// Can be removed in 3.0, once ApcCache support is dropped // Can be removed in 3.0, once ApcCache support is dropped
->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; }) ->ifString()->then(function ($v) {
if ('apc' === $v) {
@trigger_error('The ability to pass "apc" as the framework.validation.cache configuration key value is deprecated since version 2.8 and will be removed in 3.0. Use the "validator.mapping.cache.doctrine.apc" service id instead.', E_USER_DEPRECATED);
return 'validator.mapping.cache.apc';
}
return $v;
})
->end() ->end()
->end() ->end()
->booleanNode('enable_annotations')->defaultFalse()->end() ->booleanNode('enable_annotations')->defaultFalse()->end()

View File

@ -37,6 +37,7 @@
<service id="validator.mapping.cache.apc" class="%validator.mapping.cache.apc.class%" public="false"> <service id="validator.mapping.cache.apc" class="%validator.mapping.cache.apc.class%" public="false">
<argument>%validator.mapping.cache.prefix%</argument> <argument>%validator.mapping.cache.prefix%</argument>
<deprecated>The "%service_id%" service is deprecated since Symfony 2.5 and will be removed in 3.0.</deprecated>
</service> </service>
<service id="validator.mapping.cache.doctrine.apc" class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache" public="false"> <service id="validator.mapping.cache.doctrine.apc" class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache" public="false">
@ -47,7 +48,6 @@
</call> </call>
</service> </service>
</argument> </argument>
<deprecated>The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0.</deprecated>
</service> </service>
<service id="validator.validator_factory" class="%validator.validator_factory.class%" public="false"> <service id="validator.validator_factory" class="%validator.validator_factory.class%" public="false">

View File

@ -55,7 +55,7 @@ $container->loadFromExtension('framework', array(
), ),
'validation' => array( 'validation' => array(
'enabled' => true, 'enabled' => true,
'cache' => 'apc', 'cache' => 'validator.mapping.cache.doctrine.apc',
), ),
'annotations' => array( 'annotations' => array(
'cache' => 'file', 'cache' => 'file',

View File

@ -37,7 +37,7 @@
<framework:translator enabled="true" fallback="fr" logging="true"> <framework:translator enabled="true" fallback="fr" logging="true">
<framework:path>%kernel.root_dir%/Fixtures/translations</framework:path> <framework:path>%kernel.root_dir%/Fixtures/translations</framework:path>
</framework:translator> </framework:translator>
<framework:validation enabled="true" cache="apc" /> <framework:validation enabled="true" cache="validator.mapping.cache.doctrine.apc" />
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" /> <framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
<framework:serializer enabled="true" enable-annotations="true" cache="serializer.mapping.cache.apc" name-converter="serializer.name_converter.camel_case_to_snake_case" /> <framework:serializer enabled="true" enable-annotations="true" cache="serializer.mapping.cache.apc" name-converter="serializer.name_converter.camel_case_to_snake_case" />
</framework:config> </framework:config>

View File

@ -43,7 +43,7 @@ framework:
paths: ['%kernel.root_dir%/Fixtures/translations'] paths: ['%kernel.root_dir%/Fixtures/translations']
validation: validation:
enabled: true enabled: true
cache: apc cache: validator.mapping.cache.doctrine.apc
annotations: annotations:
cache: file cache: file
debug: true debug: true

View File

@ -295,7 +295,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('addMethodMapping', $calls[4][0]); $this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setMetadataCache', $calls[5][0]); $this->assertSame('setMetadataCache', $calls[5][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]); $this->assertEquals(array(new Reference('validator.mapping.cache.doctrine.apc')), $calls[5][1]);
} }
/** /**