Skip to content

[Cache] Deprecate DoctrineProvider #40908

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE-5.4.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
UPGRADE FROM 5.3 to 5.4
=======================

Cache
-----

* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package`

FrameworkBundle
---------------

Expand Down
5 changes: 5 additions & 0 deletions UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ DoctrineBridge

* Remove `UserLoaderInterface::loadUserByUsername()` in favor of `UserLoaderInterface::loadUserByIdentifier()`

Cache
-----

* Remove `DoctrineProvider` because it has been added to the `doctrine/cache` package

Config
------

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"cache/integration-tests": "dev-master",
"composer/package-versions-deprecated": "^1.8",
"doctrine/annotations": "^1.12",
"doctrine/cache": "^1.6|^2.0",
"doctrine/cache": "^1.11|^2.0",
"doctrine/collections": "~1.0",
"doctrine/data-fixtures": "^1.1",
"doctrine/dbal": "^2.10|^3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
use Symfony\Component\Cache\DoctrineProvider;

/**
* Warms up annotation caches for classes found in composer's autoload class map
Expand Down Expand Up @@ -56,7 +56,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
$annotatedClasses = include $annotatedClassPatterns;
$reader = class_exists(PsrCachedReader::class)
? new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug)
: new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug)
: new CachedReader($this->annotationReader, DoctrineProvider::wrap($arrayAdapter), $this->debug)
;

foreach ($annotatedClasses as $class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
use Symfony\Component\Cache\DoctrineProvider;

return static function (ContainerConfigurator $container) {
$container->services()
Expand All @@ -36,9 +36,11 @@
->set('annotations.cached_reader', CachedReader::class)
->args([
service('annotations.reader'),
inline_service(DoctrineProvider::class)->args([
inline_service(ArrayAdapter::class),
]),
inline_service(DoctrineProvider::class)
->factory([DoctrineProvider::class, 'wrap'])
->args([
inline_service(ArrayAdapter::class),
]),
abstract_arg('Debug-Flag'),
])

Expand All @@ -50,6 +52,7 @@
])

->set('annotations.filesystem_cache', DoctrineProvider::class)
->factory([DoctrineProvider::class, 'wrap'])
->args([
service('annotations.filesystem_cache_adapter'),
])
Expand All @@ -71,6 +74,7 @@
->tag('container.hot_path')

->set('annotations.cache', DoctrineProvider::class)
->factory([DoctrineProvider::class, 'wrap'])
->args([
service('annotations.cache_adapter'),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\NullAdapter;
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
use Symfony\Component\Cache\DoctrineProvider;
use Symfony\Component\Filesystem\Filesystem;

class AnnotationsCacheWarmerTest extends TestCase
Expand Down Expand Up @@ -51,7 +51,7 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
)
: new CachedReader(
$this->getReadOnlyReader(),
new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter()))
DoctrineProvider::wrap(new PhpArrayAdapter($cacheFile, new NullAdapter()))
)
;
$refClass = new \ReflectionClass($this);
Expand Down Expand Up @@ -79,7 +79,7 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
)
: new CachedReader(
$this->getReadOnlyReader(),
new DoctrineProvider($phpArrayAdapter),
DoctrineProvider::wrap($phpArrayAdapter),
true
)
;
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"require-dev": {
"doctrine/annotations": "^1.10.4",
"doctrine/cache": "^1.0|^2.0",
"doctrine/cache": "^1.11|^2.0",
"doctrine/persistence": "^1.3|^2.0",
"symfony/asset": "^5.3|^6.0",
"symfony/browser-kit": "^5.4|^6.0",
Expand Down Expand Up @@ -70,6 +70,7 @@
"symfony/phpunit-bridge": "^5.3|^6.0"
},
"conflict": {
"doctrine/cache": "<1.11",
"doctrine/persistence": "<1.3",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Cache/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

5.4
---

* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package

5.3
---

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Cache/DoctrineProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@

/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @deprecated Use Doctrine\Common\Cache\Psr6\DoctrineProvider instead
*/
class DoctrineProvider extends CacheProvider implements PruneableInterface, ResettableInterface
{
private $pool;

public function __construct(CacheItemPoolInterface $pool)
{
trigger_deprecation('symfony/cache', '5.4', '"%s" is deprecated, use "Doctrine\Common\Cache\Psr6\DoctrineProvider" instead.');

$this->pool = $pool;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Cache/Tests/DoctrineProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\DoctrineProvider;

/**
* @group legacy
*/
class DoctrineProviderTest extends TestCase
{
public function testProvider()
Expand Down
13 changes: 1 addition & 12 deletions src/Symfony/Component/Validator/ValidatorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\DoctrineProvider as SymfonyDoctrineProvider;
use Symfony\Component\Validator\Context\ExecutionContextFactory;
use Symfony\Component\Validator\Exception\LogicException;
use Symfony\Component\Validator\Exception\ValidatorException;
Expand Down Expand Up @@ -437,20 +436,10 @@ private function createAnnotationReader(): Reader
}

// Doctrine Annotations < 1.13, Doctrine Cache >= 1.11, Symfony Cache
if (class_exists(CachedReader::class) && class_exists(DoctrineProvider::class) && class_exists(ArrayAdapter::class)) {
if (class_exists(CachedReader::class) && class_exists(ArrayAdapter::class)) {
return new CachedReader(new AnnotationReader(), DoctrineProvider::wrap(new ArrayAdapter()));
}

// Doctrine Annotations < 1.13, Doctrine Cache < 1.11, Symfony Cache
if (class_exists(CachedReader::class) && !class_exists(DoctrineProvider::class) && class_exists(ArrayAdapter::class)) {
return new CachedReader(new AnnotationReader(), new SymfonyDoctrineProvider(new ArrayAdapter()));
}

// Doctrine Annotations < 1.13, Doctrine Cache < 1.11
if (class_exists(CachedReader::class) && class_exists(ArrayCache::class)) {
return new CachedReader(new AnnotationReader(), new ArrayCache());
}

// Doctrine Annotation >= 1.13, Doctrine Cache >= 2, no Symfony Cache
if (class_exists(PsrCachedReader::class)) {
throw new LogicException('Enabling annotation based constraint mapping requires the package symfony/cache to be installed.');
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Validator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
"symfony/property-info": "^5.3|^6.0",
"symfony/translation": "^4.4|^5.0|^6.0",
"doctrine/annotations": "^1.10.4",
"doctrine/cache": "^1.0|^2.0",
"doctrine/cache": "^1.11|^2.0",
"egulias/email-validator": "^2.1.10|^3"
},
"conflict": {
"doctrine/cache": "<1.11",
"doctrine/lexer": "<1.0.2",
"phpunit/phpunit": "<5.4.3",
"symfony/dependency-injection": "<4.4",
Expand Down