Skip to content

[FrameworkBundle] Remove dependency on Doctrine cache #23131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2017

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Jun 11, 2017

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.

@fabpot fabpot changed the title [FrameworkBundle] Remove depdnency on Doctrine cache [FrameworkBundle] Remove dependency on Doctrine cache Jun 11, 2017
UPGRADE-3.3.md Outdated
@@ -165,6 +165,9 @@ Form
FrameworkBundle
---------------

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

@xabbuh xabbuh Jun 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be part of the UPGRADE-3.4.md file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@xabbuh
Copy link
Member

xabbuh commented Jun 11, 2017

I think we also need check for the existence of the Doctrine Cache package when annotation support is enabled in the config as by default we use a caching annotation reader.

->beforeNormalization()
// Can be removed in 4.0, when validator.mapping.cache.apc is removed
->ifString()->then(function ($v) {
if ('validator.mapping.cache.apc' === $v && !class_exists('Doctrine\Common\Cache\ApcCache')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be validator.mapping.cache.doctrine.apc ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@stof
Copy link
Member

stof commented Jun 12, 2017

@xabbuh is right about the annotation reader

@fabpot fabpot force-pushed the doctrine-cache-removal branch from 1161555 to 1c33f02 Compare June 12, 2017 15:02
@fabpot
Copy link
Member Author

fabpot commented Jun 12, 2017

check on annotations added

@@ -1217,6 +1217,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
}

if (!class_exists('Doctrine\Common\Cache\ApcCache')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check the existence of the interface rather than loading a particular implementation (which will not be the one we will use).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -1217,6 +1217,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
}

if (!class_exists('Doctrine\Common\Cache\ApcCache')) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this exception must be inside the if ('none' !== $config['cache']) {. We don't need the doctrine/cache library when disabling the annotation caching.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@fabpot fabpot force-pushed the doctrine-cache-removal branch from 1c33f02 to a4e336e Compare June 12, 2017 16:10
@fabpot fabpot merged commit a4e336e into symfony:3.4 Jun 12, 2017
fabpot added a commit that referenced this pull request Jun 12, 2017
…(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
fabpot added a commit that referenced this pull request Jun 14, 2017
… failing unit tests (derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBundle] Add Doctrine Cache to dev dependencies to fix failing unit tests

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

Currently, the unit tests of TwigBundle are failing because Doctrine Cache is missing. Before the changes of #23131, this dependency was pulled via FrameworkBundle. This PR adds Doctrine Cache to the dev dependencies of TwigBundle, so the tests pass again.

```
There were 3 errors:

1) Symfony\Bundle\TwigBundle\Tests\CacheWarmingTest::testCacheIsProperlyWarmedWhenTemplatingIsAvailable
Symfony\Component\DependencyInjection\Exception\LogicException: Annotations cannot be enabled as the Doctrine Cache library is not installed.

2) Symfony\Bundle\TwigBundle\Tests\CacheWarmingTest::testCacheIsProperlyWarmedWhenTemplatingIsDisabled
Symfony\Component\DependencyInjection\Exception\LogicException: Annotations cannot be enabled as the Doctrine Cache library is not installed.

3) Symfony\Bundle\TwigBundle\Tests\NoTemplatingEntryTest::test
Symfony\Component\DependencyInjection\Exception\LogicException: Annotations cannot be enabled as the Doctrine Cache library is not installed.
```

Commits
-------

2dfde58 Add Doctrine Cache to dev dependencies to fix failing unit tests.
@fabpot fabpot deleted the doctrine-cache-removal branch September 11, 2017 18:18
This was referenced Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants