Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Deprecation of DoctrineCacheBundle #156

Closed
alcaeus opened this issue Apr 21, 2019 · 16 comments
Closed

Deprecation of DoctrineCacheBundle #156

alcaeus opened this issue Apr 21, 2019 · 16 comments
Milestone

Comments

@alcaeus
Copy link
Member

alcaeus commented Apr 21, 2019

After evaluation, we have decided that we will not adapt this bundle for compatibility with Symfony 5. We will provide limited support while people continue to use it with Symfony 3.4 LTS and supported versions of Symfony 4, but we actively suggest people don't use this bundle anymore to configure caches from Symfony 5 onwards.

With Symfony 3.4, the Symfony Cache Component was introduced, along with a very simple way to configure it using FrameworkBundle. Unlike doctrine/cache, this component is compatible with the PHP-FIG cache standards (PSR-6 and PSR-16). With this in mind, symfony/cache is more interoperable than doctrine/cache, which was always specifically tailored to the needs of the Doctrine projects.

Last but not least, the cache bundle is no longer needed to configure caches for the DoctrineBundle: the current Symfony Flex recipe already configures symfony/cache adapters for ORM, and the new version of the bundle for ORM will support configuring a symfony/cache straight from the configuration. With all this in mind, there is no point allowing to configure doctrine/cache for anything other than it was originally intended to be used, which renders this bundle obsolete.

Please note that while we are preparing for DoctrineBundle to no longer depend on this bundle, we welcome feedback from the community on the deprecation of DoctrineCacheBundle. Please let us know if you are actively using this bundle to configure caches for usages outside of doctrine/orm. If you don't have a doctrine_cache node in your Symfony configuration, this deprecation will most likely not affect you at all. If you do, we'd appreciate your input.

@DavG
Copy link

DavG commented Apr 23, 2019

Do you have a doc explaining how to make Doctrine works with Symfony Cache ?

Each times I tried, it was not working (cache:clear fails).

If I remember correctly, doctrine (I've forget what package exactly) was not compatible with PHP-FIG standard... so I always ended up by installing DoctrineCacheBundle...

Zales0123 added a commit to Sylius/Sylius that referenced this issue Apr 24, 2019
…BAC (pamil)

This PR was merged into the 1.3 branch.

Discussion
----------

Related to doctrine/DoctrineCacheBundle#156.

Commits
-------

a332334 Remove dead configuration related to pre-stable Sylius RBAC
@SenseException
Copy link
Member

  • Are we going to abandon the composer package at a specific time?
  • To spread the information about the deprecation, we have to update the documentation. I also created a PR Create pull request template with deprecation info #157 to communicate this deprecation info to contributors.

@alcaeus
Copy link
Member Author

alcaeus commented Apr 24, 2019

@DavG:

Do you have a doc explaining how to make Doctrine works with Symfony Cache ?

Currently, you just create the cache pool you want to use, then create a DoctrineAdapter, as shown in the default recipe: https://github.com/symfony/recipes/blob/master/doctrine/doctrine-bundle/1.6/config/packages/prod/doctrine.yaml

With the new minor release of DoctrineBundle (to be released in May) you'll be able to specify a pool directly instead of having to wrap it in a DoctrineAdapter yourself.

Each times I tried, it was not working (cache:clear fails).

If I remember correctly, doctrine (I've forget what package exactly) was not compatible with PHP-FIG standard... so I always ended up by installing DoctrineCacheBundle...

That's correct - doctrine/cache does not implement PSR-6 or PSR-16, but this can be worked around (e.g. with the DoctrineAdapter class in symfony/cache)

@SenseException:

  • Are we going to abandon the composer package at a specific time?

No decision on this yet since we'll fix bugs in the latest minor release for some time to come.

@dbu
Copy link
Member

dbu commented May 29, 2019

Are we going to abandon the composer package at a specific time?

No decision on this yet since we'll fix bugs in the latest minor release for some time to come.

i would not mark it as abandon right now, but maybe in summer? it will make people aware and make them move away. the README of this repo should clearly explain what is meant with the abandon and that for now its okay to keep using it in legacy projects. it might make sense to do a PR on the symfony/cache DoctrineAdaptor as well, to mark that one as deprecated (with an explanation) so that people notice.

@alcaeus
Copy link
Member Author

alcaeus commented May 29, 2019

it might make sense to do a PR on the symfony/cache DoctrineAdaptor as well, to mark that one as deprecated

Except that the DoctrineAdapter won't be deprecated: it's still necessary to allow using a PSR cache with any project expecting a doctrine/cache instance. Note that the deprecation only affects the bundle and using the bundle to configure doctrine/cache instances in Symfony Projects. The cache library itself is unaffected so far.

@dbu
Copy link
Member

dbu commented May 29, 2019

ups, sorry. i did not realize that. yeah then the adapter still makes sense. i'd add to the deprection/abandon information that this is only about the bundle, and doctrine/cache remains maintained and used.
the readme of this repo should explain things as well.

@k00ni
Copy link

k00ni commented Nov 20, 2019

Small hint: In case you are running DoctrineCacheBundle with Symfony 4.3 and use

Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],

in your bundles.php, you might get an error after running composer update:

Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineCacheBundle" from namespace "Doctrine\Bundle\DoctrineCacheBundle".
!! Did you forget a "use" statement for another namespace? in /var/www/html/src/App/Kernel.php on line 43

Fix: Just remove the line above and everything seems fine.

Here is my composer.json:

"require": {
        "php": "^7.3",
        "ext-iconv": "*",
        "erusev/parsedown": "~1.7.3",
        "genkgo/mail": "~2.5.4",
        "jaybizzle/crawler-detect": "^1.2.84",
        "league/iso3166": "^2.1.1",
        "php-curl-class/php-curl-class": "~8.6.0",
        "sensio/framework-extra-bundle": "~5.4.1",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "~4.3.3",
        "symfony/cache": "~4.3.3",
        "symfony/console": "~4.3.3",
        "symfony/dotenv": "~4.3.3",
        "symfony/flex": "~1.4.5",
        "symfony/form": "~4.3.3",
        "symfony/framework-bundle": "~4.3.3",
        "symfony/monolog-bundle": "~3.4.0",
        "symfony/orm-pack": "^1.0",
        "symfony/property-access": "~4.3.3",
        "symfony/security-bundle": "4.3.*",
        "symfony/serializer": "~4.3.3",
        "symfony/twig-bridge": "~4.3.3",
        "symfony/twig-bundle": "~4.3.3",
        "symfony/validator": "~4.3.3",
        "symfony/yaml": "~4.3.3",
        "twig/extensions": "~1.5.4",
        "twig/twig": "~2.11.3"
}

@stof
Copy link
Member

stof commented Nov 20, 2019

@k00ni that looks weird. This bundles.php file is managed by Flex, which should remove the line automatically when DoctrineCacheBundle gets removed from the dependencies.

@alcaeus
Copy link
Member Author

alcaeus commented Nov 20, 2019

@k00ni: I’ll investigate this later. Did you upgrade DoctrineBundle from 1.x to 2.x which triggered this error?

@k00ni
Copy link

k00ni commented Nov 20, 2019

@stof wrote:

@k00ni that looks weird. This bundles.php file is managed by Flex, which should remove the line automatically when DoctrineCacheBundle gets removed from the dependencies.

My project was created with Symfony 4.0 and adapted a lot since back then. Sometimes Flex adapts files via a recipe, but sometimes it doesn't. Any info about it available?

@alcaeus wrote:

@k00ni: I’ll investigate this later. Did you upgrade DoctrineBundle from 1.x to 2.x which triggered this error?

I only use Doctrine via symfony/orm-pack. Based on my composer.lock it upgraded doctrine/doctrine-bundle from 1.11.2 to 2.0.0 recently. Could that be the cause?

@morrisonlevi
Copy link

morrisonlevi commented Nov 20, 2019

I think I'm hitting this same issue with a project that was initially Symfony 4.0. I manually removed the line that looks like this fromconfig/bundles.php to get it working:

Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],

My doctrine-bundle is at 2.0 as well. I'm not sure which component made that change, but it's definitely breaking. Is there a composer command I can run to figure that out?

Edit: I think symfony/orm-pack v1.0.7 changed its reqs from:
doctrine/doctrine-bundle (^1.6.10)

to:
doctrine/doctrine-bundle (^1.6.10|^2.0)

morrisonlevi added a commit to DataDog/dd-trace-php that referenced this issue Nov 20, 2019
Recently we have had some CI failures due to DoctrineCacheBundle,
and we are not alone; see:

doctrine/DoctrineCacheBundle#156 (comment)
@alcaeus
Copy link
Member Author

alcaeus commented Nov 21, 2019

I only use Doctrine via symfony/orm-pack. Based on my composer.lock it upgraded doctrine/doctrine-bundle from 1.11.2 to 2.0.0 recently. Could that be the cause?

I think you found the cause. I have a rough idea and will test that out later. Thanks!

@alcaeus
Copy link
Member Author

alcaeus commented Nov 26, 2019

Note that we haven't been able to reproduce this with an empty project: flex always properly removed the DoctrineCacheBundle entry from bundles.php. If someone has a reproducible test application, please share it with us so we can further investigate this. Thanks!

@dzschille
Copy link

I had the same error like @k00ni . I have a Symfony 4.3 application and installed doctrine via "symfony/orm-pack": "^1.0". After a simple composer update i got the error message. I could see in the composer.lock that the doctrine-bundle was upgraded to 2.0.

So i unpacked the orm-pack with composer unpack orm and removed the the 2.0 version:

"doctrine/doctrine-bundle": "^1.6.10",
"doctrine/doctrine-migrations-bundle": "^1.3",

Now the error is gone. I still have the line

Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],

in the bundles.php.

@dzschille
Copy link

Doctrine 2.0.1 was released which fixed this issue for me. The update removes also my DoctrineCacheBundle line from bundles.php.

If you still have a error message after the update, like "cannot autowire service argument ..." just follow the Doctrine upgrade guide.

@alcaeus alcaeus changed the title [RFC] Deprecation of DoctrineCacheBundle Deprecation of DoctrineCacheBundle Nov 29, 2019
@alcaeus alcaeus added this to the 1.4.0 milestone Nov 29, 2019
@alcaeus
Copy link
Member Author

alcaeus commented Nov 29, 2019

With 1.4.0 this bundle will be deprecated. Please read the release notes to find out more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants