Skip to content

Commit 3391ada

Browse files
fancywebnicolas-grekas
authored andcommitted
[FrameworkBundle] Ignore AnnotationException exceptions in the AnnotationsCacheWarmer
1 parent d7a161d commit 3391ada

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CacheWarmer/AnnotationsCacheWarmer.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
1313

14+
use Doctrine\Common\Annotations\AnnotationException;
1415
use Doctrine\Common\Annotations\CachedReader;
1516
use Doctrine\Common\Annotations\Reader;
1617
use Psr\Cache\CacheItemPoolInterface;
@@ -75,6 +76,15 @@ public function warmUp($cacheDir)
7576
$this->readAllComponents($reader, $class);
7677
} catch (\ReflectionException $e) {
7778
// ignore failing reflection
79+
} catch (AnnotationException $e) {
80+
/*
81+
* Ignore any AnnotationException to not break the cache warming process if an Annotation is badly
82+
* configured or could not be found / read / etc.
83+
*
84+
* In particular cases, an Annotation in your code can be used and defined only for a specific
85+
* environment but is always added to the annotations.map file by some Symfony default behaviors,
86+
* and you always end up with a not found Annotation.
87+
*/
7888
}
7989
}
8090
} finally {

0 commit comments

Comments
 (0)