Skip to content

Commit dfd012b

Browse files
committed
feature #23131 [FrameworkBundle] Remove dependency on Doctrine cache (fabpot)
This PR was squashed before being merged into the 3.4 branch (closes #23131). Discussion ---------- [FrameworkBundle] Remove dependency on Doctrine cache | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | yes | Tests pass? | yes | Fixed tickets | related to symfony/flex#14 | License | MIT | Doc PR | n/a In our quest to remove hard dependencies, I propose to remove `doctrine/cache` from the default dependencies on the Framework bundle. That's possible now as we have PSR6 cache support in Symfony and because Doctrine cache is only used for the validator mapping cache. The two other occurrences are for the serializer (already deprecated in 3.3) and for annotations, where we need to keep it, but as Doctrine annotations is already optional, that's not an issue. Commits ------- a4e336ea34 [FrameworkBundle] removed doctrine/cache as a dependency b57895ccaf [FrameworkBundle] deprecated validator.mapping.cache.doctrine.apc
2 parents 5a55f2b + 4f8d68e commit dfd012b

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* Removed `doctrine/cache` from the list of required dependencies in `composer.json`
8+
* Deprecated `validator.mapping.cache.doctrine.apc` service
79
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
810
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
911

DependencyInjection/Configuration.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,18 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
661661
->info('validation configuration')
662662
->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
663663
->children()
664-
->scalarNode('cache')->end()
664+
->scalarNode('cache')
665+
->beforeNormalization()
666+
// Can be removed in 4.0, when validator.mapping.cache.doctrine.apc is removed
667+
->ifString()->then(function ($v) {
668+
if ('validator.mapping.cache.doctrine.apc' === $v && !class_exists('Doctrine\Common\Cache\ApcCache')) {
669+
throw new LogicException('Doctrine APC cache for the validator cannot be enabled as the Doctrine Cache package is not installed.');
670+
}
671+
672+
return $v;
673+
})
674+
->end()
675+
->end()
665676
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
666677
->arrayNode('static_method')
667678
->defaultValue(array('loadValidatorMetadata'))

DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
12201220
$loader->load('annotations.xml');
12211221

12221222
if ('none' !== $config['cache']) {
1223+
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
1224+
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
1225+
}
1226+
12231227
$cacheService = $config['cache'];
12241228

12251229
if ('php_array' === $config['cache']) {

Resources/config/validator.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
</call>
5858
</service>
5959
</argument>
60+
<deprecated>The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use a Psr6 cache like "validator.mapping.cache.symfony" instead.</deprecated>
6061
</service>
6162

6263
<service id="validator.validator_factory" class="Symfony\Component\Validator\ContainerConstraintValidatorFactory">

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"symfony/filesystem": "~2.8|~3.0|~4.0",
3030
"symfony/finder": "~2.8|~3.0|~4.0",
3131
"symfony/routing": "~3.4|~4.0",
32-
"symfony/stopwatch": "~2.8|~3.0|~4.0",
33-
"doctrine/cache": "~1.0"
32+
"symfony/stopwatch": "~2.8|~3.0|~4.0"
3433
},
3534
"require-dev": {
35+
"doctrine/cache": "~1.0",
3636
"fig/link-util": "^1.0",
3737
"symfony/asset": "~3.3|~4.0",
3838
"symfony/browser-kit": "~2.8|~3.0|~4.0",

0 commit comments

Comments
 (0)