Skip to content

Commit 10a3c32

Browse files
bug #20725 [HttpKernel] Fix annotation cache warmer with failing or missing classes (nicolas-grekas)
This PR was merged into the 3.2 branch. Discussion ---------- [HttpKernel] Fix annotation cache warmer with failing or missing classes | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20720 | License | MIT | Doc PR | - Commits ------- dcf9fbb [HttpKernel] Fix annotation cache warmer with failing or missing classes
2 parents 6df0cde + 42616f9 commit 10a3c32

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,19 @@ public function warmUp($cacheDir)
6666

6767
$arrayPool = new ArrayAdapter(0, false);
6868
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayPool));
69-
70-
foreach ($annotatedClasses as $class) {
71-
$this->readAllComponents($reader, $class);
69+
$throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
70+
spl_autoload_register($throwingAutoloader);
71+
72+
try {
73+
foreach ($annotatedClasses as $class) {
74+
try {
75+
$this->readAllComponents($reader, $class);
76+
} catch (\ReflectionException $e) {
77+
// ignore failing reflection
78+
}
79+
}
80+
} finally {
81+
spl_autoload_unregister($throwingAutoloader);
7282
}
7383

7484
$values = $arrayPool->getValues();

0 commit comments

Comments
 (0)