Skip to content

Commit dcf9fbb

Browse files
[HttpKernel] Fix annotation cache warmer with failing or missing classes
1 parent 8c22de4 commit dcf9fbb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/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();

src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private function getClassesInComposerClassMaps()
101101
}
102102

103103
if (is_array($function) && $function[0] instanceof ClassLoader) {
104-
$classes += $function[0]->getClassMap();
104+
$classes += array_filter($function[0]->getClassMap());
105105
}
106106
}
107107

0 commit comments

Comments
 (0)