Skip to content

Commit

Permalink
feature #23131 [FrameworkBundle] Remove dependency on Doctrine cache …
Browse files Browse the repository at this point in the history
…(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
  • Loading branch information
fabpot committed Jun 12, 2017
2 parents 8bbfc96 + a4e336e commit 18ecbd7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions UPGRADE-3.4.md
Expand Up @@ -16,6 +16,11 @@ Finder
FrameworkBundle
---------------

* The `doctrine/cache` dependency has been removed; require it via `composer
require doctrine/cache` if you are using Doctrine cache in your project.

* The `validator.mapping.cache.doctrine.apc` service has been deprecated.

* Using the `KERNEL_DIR` environment variable or the automatic guessing based
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
Set the `KERNEL_CLASS` environment variable to the fully-qualified class name
Expand Down
2 changes: 2 additions & 0 deletions UPGRADE-4.0.md
Expand Up @@ -227,6 +227,8 @@ Form
FrameworkBundle
---------------

* The `validator.mapping.cache.doctrine.apc` service has been removed.

* The `cache:clear` command does not warmup the cache anymore. Warmup should
be done via the `cache:warmup` command.

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
3.4.0
-----

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

Expand Down
Expand Up @@ -661,7 +661,18 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->info('validation configuration')
->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->scalarNode('cache')->end()
->scalarNode('cache')
->beforeNormalization()
// Can be removed in 4.0, when validator.mapping.cache.doctrine.apc is removed
->ifString()->then(function ($v) {
if ('validator.mapping.cache.doctrine.apc' === $v && !class_exists('Doctrine\Common\Cache\ApcCache')) {
throw new LogicException('Doctrine APC cache for the validator cannot be enabled as the Doctrine Cache package is not installed.');
}

return $v;
})
->end()
->end()
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
->arrayNode('static_method')
->defaultValue(array('loadValidatorMetadata'))
Expand Down
Expand Up @@ -1220,6 +1220,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
$loader->load('annotations.xml');

if ('none' !== $config['cache']) {
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
}

$cacheService = $config['cache'];

if ('php_array' === $config['cache']) {
Expand Down
Expand Up @@ -57,6 +57,7 @@
</call>
</service>
</argument>
<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>
</service>

<service id="validator.validator_factory" class="Symfony\Component\Validator\ContainerConstraintValidatorFactory">
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Expand Up @@ -29,10 +29,10 @@
"symfony/filesystem": "~2.8|~3.0|~4.0",
"symfony/finder": "~2.8|~3.0|~4.0",
"symfony/routing": "~3.4|~4.0",
"symfony/stopwatch": "~2.8|~3.0|~4.0",
"doctrine/cache": "~1.0"
"symfony/stopwatch": "~2.8|~3.0|~4.0"
},
"require-dev": {
"doctrine/cache": "~1.0",
"fig/link-util": "^1.0",
"symfony/asset": "~3.3|~4.0",
"symfony/browser-kit": "~2.8|~3.0|~4.0",
Expand Down

0 comments on commit 18ecbd7

Please sign in to comment.