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
This commit is contained in:
commit
a7b5080806
@ -66,9 +66,19 @@ class AnnotationsCacheWarmer implements CacheWarmerInterface
|
||||
|
||||
$arrayPool = new ArrayAdapter(0, false);
|
||||
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayPool));
|
||||
$throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
|
||||
spl_autoload_register($throwingAutoloader);
|
||||
|
||||
foreach ($annotatedClasses as $class) {
|
||||
$this->readAllComponents($reader, $class);
|
||||
try {
|
||||
foreach ($annotatedClasses as $class) {
|
||||
try {
|
||||
$this->readAllComponents($reader, $class);
|
||||
} catch (\ReflectionException $e) {
|
||||
// ignore failing reflection
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
spl_autoload_unregister($throwingAutoloader);
|
||||
}
|
||||
|
||||
$values = $arrayPool->getValues();
|
||||
|
@ -101,7 +101,7 @@ class AddClassesToCachePass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
if (is_array($function) && $function[0] instanceof ClassLoader) {
|
||||
$classes += $function[0]->getClassMap();
|
||||
$classes += array_filter($function[0]->getClassMap());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user