From 0b3f1c710ae84b23868867eed9d0c1ce57c0c8a1 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 16 Dec 2016 14:05:12 +0100 Subject: [PATCH 1/3] [FrameworkBundle] Ignore AnnotationException exceptions in the AnnotationsCacheWarmer --- .../FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index 2c0a435617d4a..b3a2c51e0c438 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; +use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Annotations\Reader; use Psr\Cache\CacheItemPoolInterface; @@ -75,6 +76,8 @@ public function warmUp($cacheDir) $this->readAllComponents($reader, $class); } catch (\ReflectionException $e) { // ignore failing reflection + } catch (AnnotationException $e) { + } } } finally { From 7cf56c43fcbe860ac51a118af99ffd1baed59471 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Tue, 20 Dec 2016 07:53:28 +0100 Subject: [PATCH 2/3] add a short comment to explain why AnnotationException are ignored --- .../CacheWarmer/AnnotationsCacheWarmer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index b3a2c51e0c438..c7a0750507c38 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -77,7 +77,16 @@ public function warmUp($cacheDir) } catch (\ReflectionException $e) { // ignore failing reflection } catch (AnnotationException $e) { - + /* + * Ignore any AnnotationException to not break the cache warming process if an Annotation is badly + * configured or could not be found / read / etc. + * + * In particular cases, an Annotation in your code can be used and defined only for a specific + * environment but is always added to the annotations.map file by some Symfony default behaviors, + * and you always end up with a not found Annotation. + * + * cf https://github.com/symfony/symfony/pull/20959 for a longer explanation. + */ } } } finally { From 38ea36c29acb814e5b32913581362e3936c2edc5 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Tue, 27 Dec 2016 07:53:27 +0100 Subject: [PATCH 3/3] remove github link --- .../FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index c7a0750507c38..446deddab89c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -84,8 +84,6 @@ public function warmUp($cacheDir) * In particular cases, an Annotation in your code can be used and defined only for a specific * environment but is always added to the annotations.map file by some Symfony default behaviors, * and you always end up with a not found Annotation. - * - * cf https://github.com/symfony/symfony/pull/20959 for a longer explanation. */ } }