8000 feature #23131 [FrameworkBundle] Remove dependency on Doctrine cache … · symfony/symfony@18ecbd7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 18ecbd7

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 ------- a4e336e [FrameworkBundle] removed doctrine/cache as a dependency b57895c [FrameworkBundle] deprecated validator.mapping.cache.doctrine.apc
2 parents 8bbfc96 + a4e336e commit 18ecbd7

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

UPGRADE-3.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Finder
1616
FrameworkBundle
1717
---------------
1818

19+
* The `doctrine/cache` dependency has been removed; require it via `composer
20+
require doctrine/cache` if you are using Doctrine cache in your project.
21+
22+
* The `validator.mapping.cache.doctrine.apc` service has been deprecated.
23+
1924
* Using the `KERNEL_DIR` environment variable or the automatic guessing based
2025
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
2126
Set the `KERNEL_CLASS` environment variable to the fully-qualified class name

UPGRADE-4.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ Form
227227
FrameworkBundle
228228
---------------
229229

230+
* The `validator.mapping.cache.doctrine.apc` service has been removed.
231+
230232
* The `cache:clear` command does not warmup the cache anymore. Warmup should
231233
be done via the `cache:warmup` command.
232234

src/Symfony/Bundle/FrameworkBundle/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

src/Symfony/Bundle/FrameworkBundle/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'))

src/Symfony/Bundle/FrameworkBundle/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']) {

src/Symfony/Bundle/FrameworkBundle/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">

src/Symfony/Bundle/FrameworkBundle/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)
0