From dcf9fbb18c3fb73667fae79f9f678a17dcd57cc3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Dec 2016 15:52:29 +0100 Subject: [PATCH] [HttpKernel] Fix annotation cache warmer with failing or missing classes --- .../CacheWarmer/AnnotationsCacheWarmer.php | 16 +++++++++++++--- .../AddClassesToCachePass.php | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index 6d044676eb012..2c0a435617d4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -66,9 +66,19 @@ public function warmUp($cacheDir) $arrayPool = new ArrayAdapter(0, false); $reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayPool)); - - foreach ($annotatedClasses as $class) { - $this->readAllComponents($reader, $class); + $throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); }; + spl_autoload_register($throwingAutoloader); + + try { + foreach ($annotatedClasses as $class) { + try { + $this->readAllComponents($reader, $class); + } catch (\ReflectionException $e) { + // ignore failing reflection + } + } + } finally { + spl_autoload_unregister($throwingAutoloader); } $values = $arrayPool->getValues(); diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php index 0cc8d99864391..e9d012033d6d4 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php @@ -101,7 +101,7 @@ private function getClassesInComposerClassMaps() } if (is_array($function) && $function[0] instanceof ClassLoader) { - $classes += $function[0]->getClassMap(); + $classes += array_filter($function[0]->getClassMap()); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy