Skip to content

Commit cbb18f2

Browse files
committed
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
2 parents ac08db9 + 83fce46 commit cbb18f2

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

DependencyInjection/Configuration.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,15 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
645645
->scalarNode('cache')
646646
->beforeNormalization()
647647
// Can be removed in 3.0, once ApcCache support is dropped
648-
->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; })
648+
->ifString()->then(function ($v) {
649+
if ('apc' === $v) {
650+
@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);
651+
652+
return 'validator.mapping.cache.apc';
653+
}
654+
655+
return $v;
656+
})
649657
->end()
650658
->end()
651659
->booleanNode('enable_annotations')->defaultFalse()->end()

Resources/config/validator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
<service id="validator.mapping.cache.apc" class="%validator.mapping.cache.apc.class%" public="false">
3939
<argument>%validator.mapping.cache.prefix%</argument>
40+
<deprecated>The "%service_id%" service is deprecated since Symfony 2.5 and will be removed in 3.0.</deprecated>
4041
</service>
4142

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

5353
<service id="validator.validator_factory" class="%validator.validator_factory.class%" public="false">

Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
),
5656
'validation' => array(
5757
'enabled' => true,
58-
'cache' => 'apc',
58+
'cache' => 'validator.mapping.cache.doctrine.apc',
5959
),
6060
'annotations' => array(
6161
'cache' => 'file',

Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<framework:translator enabled="true" fallback="fr" logging="true">
3838
<framework:path>%kernel.root_dir%/Fixtures/translations</framework:path>
3939
</framework:translator>
40-
<framework:validation enabled="true" cache="apc" />
40+
<framework:validation enabled="true" cache="validator.mapping.cache.doctrine.apc" />
4141
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
4242
<framework:serializer enabled="true" enable-annotations="true" cache="serializer.mapping.cache.apc" name-converter="serializer.name_converter.camel_case_to_snake_case" />
4343
</framework:config>

Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ framework:
4343
paths: ['%kernel.root_dir%/Fixtures/translations']
4444
validation:
4545
enabled: true
46-
cache: apc
46+
cache: validator.mapping.cache.doctrine.apc
4747
annotations:
4848
cache: file
4949
debug: true

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public function testValidation()
295295
$this->assertSame('addMethodMapping', $calls[4][0]);
296296
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
297297
$this->assertSame('setMetadataCache', $calls[5][0]);
298-
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
298+
$this->assertEquals(array(new Reference('validator.mapping.cache.doctrine.apc')), $calls[5][1]);
299299
}
300300

301301
/**

0 commit comments

Comments
 (0)