Skip to content

Commit 48b95bb

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Add Session Token to Amazon Mailer [ErrorHandler] Update TentativeTypes Prepare removing Doctrine Cache from remaining components [ErrorHandler] Add helper script to patch type declarations [Messenger] Do not reset services on WorkerRunningEvent anymore [Messenger] Add back kernel.event_subscriber tag on StopWorkerOnCustomStopExceptionListener Display the roles of the logged-in user in the Web Debug Toolbar -- bugfix
2 parents c145f99 + 3368a4b commit 48b95bb

File tree

7 files changed

+20
-73
lines changed

7 files changed

+20
-73
lines changed

CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
1313

1414
use Doctrine\Common\Annotations\AnnotationException;
15-
use Doctrine\Common\Annotations\CachedReader;
1615
use Doctrine\Common\Annotations\PsrCachedReader;
1716
use Doctrine\Common\Annotations\Reader;
18-
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
1917
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2018
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
2119

@@ -54,10 +52,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
5452
}
5553

5654
$annotatedClasses = include $annotatedClassPatterns;
57-
$reader = class_exists(PsrCachedReader::class)
58-
? new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug)
59-
: new CachedReader($this->annotationReader, DoctrineProvider::wrap($arrayAdapter), $this->debug)
60-
;
55+
$reader = new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug);
6156

6257
foreach ($annotatedClasses as $class) {
6358
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,22 +1518,18 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
15181518

15191519
if ('none' === $config['cache']) {
15201520
$container->removeDefinition('annotations.cached_reader');
1521-
$container->removeDefinition('annotations.psr_cached_reader');
15221521

15231522
return;
15241523
}
15251524

1526-
if ($container->hasDefinition('annotations.psr_cached_reader')) {
1527-
$container->setDefinition('annotations.cached_reader', $container->getDefinition('annotations.psr_cached_reader'));
1528-
}
1529-
15301525
if ('php_array' === $config['cache']) {
1531-
$cacheService = $container->hasDefinition('annotations.psr_cached_reader') ? 'annotations.cache_adapter' : 'annotations.cache';
1526+
$cacheService = 'annotations.cache_adapter';
15321527

15331528
// Enable warmer only if PHP array is used for cache
15341529
$definition = $container->findDefinition('annotations.cache_warmer');
15351530
$definition->addTag('kernel.cache_warmer');
15361531
} else {
1532+
$cacheService = 'annotations.filesystem_cache_adapter';
15371533
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
15381534

15391535
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
@@ -1544,17 +1540,6 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
15441540
->getDefinition('annotations.filesystem_cache_adapter')
15451541
->replaceArgument(2, $cacheDir)
15461542
;
1547-
1548-
if ($container->hasDefinition('annotations.psr_cached_reader')) {
1549-
$cacheService = 'annotations.filesystem_cache_adapter';
1550-
} else {
1551-
// Legacy code for doctrine/annotations:<1.13
1552-
if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
1553-
throw new LogicException('Annotations cannot be cached as the Doctrine Cache library is not installed. Try running "composer require doctrine/cache".');
1554-
}
1555-
1556-
$cacheService = 'annotations.filesystem_cache';
1557-
}
15581543
}
15591544

15601545
$container

Resources/config/annotations.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\AnnotationRegistry;
16-
use Doctrine\Common\Annotations\CachedReader;
1716
use Doctrine\Common\Annotations\PsrCachedReader;
1817
use Doctrine\Common\Annotations\Reader;
1918
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
@@ -33,14 +32,10 @@
3332
->set('annotations.dummy_registry', AnnotationRegistry::class)
3433
->call('registerUniqueLoader', ['class_exists'])
3534

36-
->set('annotations.cached_reader', CachedReader::class)
35+
->set('annotations.cached_reader', PsrCachedReader::class)
3736
->args([
3837
service('annotations.reader'),
39-
inline_service(DoctrineProvider::class)
40-
->factory([DoctrineProvider::class, 'wrap'])
41-
->args([
42-
inline_service(ArrayAdapter::class),
43-
]),
38+
inline_service(ArrayAdapter::class),
4439
abstract_arg('Debug-Flag'),
4540
])
4641

@@ -56,6 +51,7 @@
5651
->args([
5752
service('annotations.filesystem_cache_adapter'),
5853
])
54+
->deprecate('symfony/framework-bundle', '5.4', '"%service_id% is deprecated"')
5955

6056
->set('annotations.cache_warmer', AnnotationsCacheWarmer::class)
6157
->args([
@@ -78,19 +74,8 @@
7874
->args([
7975
service('annotations.cache_adapter'),
8076
])
81-
->tag('container.hot_path')
77+
->deprecate('symfony/framework-bundle', '5.4', '"%service_id% is deprecated"')
8278

8379
->alias('annotation_reader', 'annotations.reader')
8480
->alias(Reader::class, 'annotation_reader');
85-
86-
if (class_exists(PsrCachedReader::class)) {
87-
$container->services()
88-
->set('annotations.psr_cached_reader', PsrCachedReader::class)
89-
->args([
90-
service('annotations.reader'),
91-
inline_service(ArrayAdapter::class),
92-
abstract_arg('Debug-Flag'),
93-
])
94-
;
95-
}
9681
};

Resources/config/messenger.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
->tag('kernel.event_subscriber')
197197

198198
->set('messenger.listener.stop_worker_on_stop_exception_listener', StopWorkerOnCustomStopExceptionListener::class)
199+
->tag('kernel.event_subscriber')
199200

200201
->set('messenger.listener.reset_services', ResetServicesListener::class)
201202
->args([

Tests/CacheWarmer/AnnotationsCacheWarmerTest.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
44

55
use Doctrine\Common\Annotations\AnnotationReader;
6-
use Doctrine\Common\Annotations\CachedReader;
76
use Doctrine\Common\Annotations\PsrCachedReader;
87
use Doctrine\Common\Annotations\Reader;
9-
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
108
use PHPUnit\Framework\MockObject\MockObject;
119
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
1210
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
@@ -44,16 +42,10 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
4442
$this->assertFileExists($cacheFile);
4543

4644
// Assert cache is valid
47-
$reader = class_exists(PsrCachedReader::class)
48-
? new PsrCachedReader(
49-
$this->getReadOnlyReader(),
50-
new PhpArrayAdapter($cacheFile, new NullAdapter())
51-
)
52-
: new CachedReader(
53-
$this->getReadOnlyReader(),
54-
DoctrineProvider::wrap(new PhpArrayAdapter($cacheFile, new NullAdapter()))
55-
)
56-
;
45+
$reader = new PsrCachedReader(
46+
$this->getReadOnlyReader(),
47+
new PhpArrayAdapter($cacheFile, new NullAdapter())
48+
);
5749
$refClass = new \ReflectionClass($this);
5850
$reader->getClassAnnotations($refClass);
5951
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));
@@ -71,18 +63,11 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
7163

7264
// Assert cache is valid
7365
$phpArrayAdapter = new PhpArrayAdapter($cacheFile, new NullAdapter());
74-
$reader = class_exists(PsrCachedReader::class)
75-
? new PsrCachedReader(
76-
$this->getReadOnlyReader(),
77-
$phpArrayAdapter,
78-
true
79-
)
80-
: new CachedReader(
81-
$this->getReadOnlyReader(),
82-
DoctrineProvider::wrap($phpArrayAdapter),
83-
true
84-
)
85-
;
66+
$reader = new PsrCachedReader(
67+
$this->getReadOnlyReader(),
68+
$phpArrayAdapter,
69+
true
70+
);
8671
$refClass = new \ReflectionClass($this);
8772
$reader->getClassAnnotations($refClass);
8873
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));

Tests/Functional/AutowiringTypesTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
15-
use Doctrine\Common\Annotations\CachedReader;
1615
use Doctrine\Common\Annotations\PsrCachedReader;
1716
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1817
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -34,11 +33,7 @@ public function testCachedAnnotationReaderAutowiring()
3433
static::bootKernel();
3534

3635
$annotationReader = self::getContainer()->get('test.autowiring_types.autowired_services')->getAnnotationReader();
37-
if (class_exists(PsrCachedReader::class)) {
38-
$this->assertInstanceOf(PsrCachedReader::class, $annotationReader);
39-
} else {
40-
$this->assertInstanceOf(CachedReader::class, $annotationReader);
41-
}
36+
$this->assertInstanceOf(PsrCachedReader::class, $annotationReader);
4237
}
4338

4439
public function testEventDispatcherAutowiring()

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"symfony/routing": "^5.4|^6.0"
3232
},
3333
"require-dev": {
34-
"doctrine/annotations": "^1.10.4",
34+
"doctrine/annotations": "^1.13.1",
3535
"doctrine/cache": "^1.11|^2.0",
3636
"doctrine/persistence": "^1.3|^2.0",
3737
"symfony/asset": "^5.4|^6.0",
@@ -68,6 +68,7 @@
6868
"symfony/phpunit-bridge": "^5.4|^6.0"
6969
},
7070
"conflict": {
71+
"doctrine/annotations": "<1.13.1",
7172
"doctrine/cache": "<1.11",
7273
"doctrine/persistence": "<1.3",
7374
"phpdocumentor/reflection-docblock": "<3.2.2",

0 commit comments

Comments
 (0)