8000 [Cache] Deprecate DoctrineProvider · symfony/symfony@5fb1867 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fb1867

Browse files
committed
[Cache] Deprecate DoctrineProvider
1 parent ba2a354 commit 5fb1867

File tree

13 files changed

+60
-16
lines changed

13 files changed

+60
-16
lines changed

UPGRADE-5.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
UPGRADE FROM 5.3 to 5.4
2+
=======================
3+
4+
Cache
5+
-----
6+
7+
* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package`

UPGRADE-6.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ DoctrineBridge
1111

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

14+
Cache
15+
-----
16+
17+
* Remove `DoctrineProvider` because it has been added to the `doctrine/cache` package
18+
1419
Config
1520
------
1621

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"cache/integration-tests": "dev-master",
126126
"composer/package-versions-deprecated": "^1.8",
127127
"doctrine/annotations": "^1.12",
128-
"doctrine/cache": "~1.6",
128+
"doctrine/cache": "^1.11",
129129
"doctrine/collections": "~1.0",
130130
"doctrine/data-fixtures": "^1.1",
131131
"doctrine/dbal": "^2.10|^3.0",

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
use Doctrine\Common\Annotations\CachedReader;
1616
use Doctrine\Common\Annotations\PsrCachedReader;
1717
use Doctrine\Common\Annotations\Reader;
18+
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
1819
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1920
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
20-
use Symfony\Component\Cache\DoctrineProvider;
2121

2222
/**
2323
* Warms up annotation caches for classes found in composer's autoload class map
@@ -59,7 +59,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
5959
// doctrine/annotations:1.13 and above
6060
$reader = new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug);
6161
} else {
62-
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug);
62+
$reader = new CachedReader($this->annotationReader, DoctrineProvider::wrap($arrayAdapter), $this->debug);
6363
}
6464

6565
foreach ($annotatedClasses as $class) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
use Doctrine\Common\Annotations\CachedReader;
1717
use Doctrine\Common\Annotations\PsrCachedReader;
1818
use Doctrine\Common\Annotations\Reader;
19+
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
1920
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
2021
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2122
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
2223
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
23-
use Symfony\Component\Cache\DoctrineProvider;
2424

2525
return static function (ContainerConfigurator $container) {
2626
$container->services()
@@ -36,9 +36,11 @@
3636
->set('annotations.cached_reader', CachedReader::class)
3737
->args([
3838
service('annotations.reader'),
39-
inline_service(DoctrineProvider::class)->args([
40-
inline_service(ArrayAdapter::class),
41-
]),
39+
inline_service(DoctrineProvider::class)
40+
->factory([DoctrineProvider::class, 'wrap'])
41+
->args([
42+
inline_service(ArrayAdapter::class),
43+
]),
4244
abstract_arg('Debug-Flag'),
4345
])
4446

@@ -50,6 +52,7 @@
5052
])
5153

5254
->set('annotations.filesystem_cache', DoctrineProvider::class)
55+
->factory([DoctrineProvider::class, 'wrap'])
5356
->args([
5457
service('annotations.filesystem_cache_adapter'),
5558
])
@@ -63,6 +66,7 @@
6366
])
6467

6568
->set('annotations.cache', DoctrineProvider::class)
69+
->factory([DoctrineProvider::class, 'wrap'])
6670
->args([
6771
inline_service(PhpArrayAdapter::class)
6872
->factory([PhpArrayAdapter::class, 'create'])

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
use Doctrine\Common\Annotations\CachedReader;
77
use Doctrine\Common\Annotations\PsrCachedReader;
88
use Doctrine\Common\Annotations\Reader;
9+
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
910
use PHPUnit\Framework\MockObject\MockObject;
1011
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
1112
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1213
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1314
use Symfony\Component\Cache\Adapter\NullAdapter;
1415
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
15-
use Symfony\Component\Cache\DoctrineProvider;
1616
use Symfony\Component\Filesystem\Filesystem;
1717

1818
class AnnotationsCacheWarmerTest extends TestCase
@@ -48,7 +48,7 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
4848
if (class_exists(PsrCachedReader::class)) {
4949
$reader = new PsrCachedReader($this->getReadOnlyReader(), $psr6Cache);
5050
} else {
51-
$reader = new CachedReader($this->getReadOnlyReader(), new DoctrineProvider($psr6Cache));
51+
$reader = new CachedReader($this->getReadOnlyReader(), DoctrineProvider::wrap($psr6Cache));
5252
}
5353

5454
$refClass = new \ReflectionClass($this);
@@ -71,7 +71,7 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
7171
if (class_exists(PsrCachedReader::class)) {
7272
$reader = new PsrCachedReader($this->getReadOnlyReader(), $psr6Cache);
7373
} else {
74-
$reader = new CachedReader($this->getReadOnlyReader(), new DoctrineProvider($psr6Cache));
74+
$reader = new CachedReader($this->getReadOnlyReader(), DoctrineProvider::wrap($psr6Cache));
7575
}
7676

7777
$refClass = new \ReflectionClass($this);

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"doctrine/annotations": "^1.10.4",
37-
"doctrine/cache": "~1.0",
37+
"doctrine/cache": "^1.11",
3838
"doctrine/persistence": "^1.3|^2.0",
3939
"symfony/asset": "^5.3",
4040
"symfony/browser-kit": "^4.4|^5.0",
@@ -102,6 +102,7 @@
102102
"symfony/phpunit-bridge": "^5.3"
103103
},
104104
"conflict": {
105+
"doctrine/cache": "<1.11",
105106
"doctrine/persistence": "<1.3",
106107
"phpdocumentor/reflection-docblock": "<3.2.2",
107108
"phpdocumentor/type-resolver": "<1.4.0",

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.4
5+
---
6+
7+
* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package
8+
49
5.3
510
---
611

src/Symfony/Component/Cache/DoctrineProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717

1818
/**
1919
* @author Nicolas Grekas <p@tchwork.com>
20+
*
21+
* @deprecated Use Doctrine\Common\Cache\Psr6\DoctrineProvider instead
2022
*/
2123
class DoctrineProvider extends CacheProvider implements PruneableInterface, ResettableInterface
2224
{
2325
private $pool;
2426

2527
public function __construct(CacheItemPoolInterface $pool)
2628
{
29+
trigger_deprecation('symfony/cache', '5.4', '"%s" is deprecated, use "Doctrine\Common\Cache\Psr6\DoctrineProvider" instead.');
30+
2731
$this->pool = $pool;
2832
}
2933

src/Symfony/Component/Cache/Tests/DoctrineProviderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1717
use Symfony\Component\Cache\DoctrineProvider;
1818

19+
/**
20+
* @group legacy
21+
*/
1922
class DoctrineProviderTest extends TestCase
2023
{
2124
public function testProvider()

src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests;
1313

1414
use Doctrine\Common\Annotations\CachedReader;
15+
use Doctrine\Common\Annotations\PsrCachedReader;
1516
use Doctrine\Common\Annotations\Reader;
1617
use PHPUnit\Framework\TestCase;
1718
use Psr\Cache\CacheItemPoolInterface;
@@ -99,7 +100,11 @@ public function testEnableAnnotationMapping()
99100
$r = new \ReflectionProperty(AnnotationLoader::class, 'reader');
100101
$r->setAccessible(true);
101102

102-
$this->assertInstanceOf(CachedReader::class, $r->getValue($loaders[0]));
103+
if (class_exists(PsrCachedReader::class)) {
104+
$this->assertInstanceOf(PsrCachedReader::class, $r->getValue($loaders[0]));
105+
} else {
106+
$this->assertInstanceOf(CachedReader::class, $r->getValue($loaders[0]));
107+
}
103108
}
104109

105110
public function testEnableAnnotationMappingWithDefaultDoctrineAnnotationReader()
@@ -114,7 +119,11 @@ public function testEnableAnnotationMappingWithDefaultDoctrineAnnotationReader()
114119
$r = new \ReflectionProperty(AnnotationLoader::class, 'reader');
115120
$r->setAccessible(true);
116121

117-
$this->assertInstanceOf(CachedReader::class, $r->getValue($loaders[0]));
122+
if (class_exists(PsrCachedReader::class)) {
123+
$this->assertInstanceOf(PsrCachedReader::class, $r->getValue($loaders[0]));
124+
} else {
125+
$this->assertInstanceOf(CachedReader::class, $r->getValue($loaders[0]));
126+
}
118127
}
119128

120129
/**

src/Symfony/Component/Validator/ValidatorBuilder.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\CachedReader;
16+
use Doctrine\Common\Annotations\PsrCachedReader;
1617
use Doctrine\Common\Annotations\Reader;
1718
use Doctrine\Common\Cache\ArrayCache;
19+
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
1820
use Psr\Cache\CacheItemPoolInterface;
1921
use Symfony\Component\Cache\Adapter\ArrayAdapter;
20-
use Symfony\Component\Cache\DoctrineProvider;
2122
use Symfony\Component\Validator\Context\ExecutionContextFactory;
2223
use Symfony\Component\Validator\Exception\ValidatorException;
2324
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
@@ -269,7 +270,11 @@ public function setDoctrineAnnotationReader(?Reader $reader): self
269270
public function addDefaultDoctrineAnnotationReader(): self
270271
{
271272
if (class_exists(ArrayAdapter::class)) {
272-
$this->annotationReader = new CachedReader(new AnnotationReader(), new DoctrineProvider(new ArrayAdapter()));
273+
if (class_exists(PsrCachedReader::class)) {
274+
$this->annotationReader = new PsrCachedReader(new AnnotationReader(), new ArrayAdapter());
275+
} else {
276+
$this->annotationReader = new CachedReader(new AnnotationReader(), DoctrineProvider::wrap(new ArrayAdapter()));
277+
}
273278
} else {
274279
$this->annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
275280
}

src/Symfony/Component/Validator/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@
4141
"symfony/property-info": "^5.3",
4242
"symfony/translation": "^4.4|^5.0",
4343
"doctrine/annotations": "^1.10.4",
44-
"doctrine/cache": "~1.0",
44+
"doctrine/cache": "^1.11",
4545
"egulias/email-validator": "^2.1.10|^3"
4646
},
4747
"conflict": {
48+
"doctrine/cache": "<1.11",
4849
"doctrine/lexer": "<1.0.2",
4950
"phpunit/phpunit": "<5.4.3",
5051
"symfony/dependency-injection": "<4.4",

0 commit comments

Comments
 (0)
0