diff --git a/src/Symfony/Framework/ClassCollectionLoader.php b/src/Symfony/Framework/ClassCollectionLoader.php index d4d36a1298b6..f6a3808fe06a 100644 --- a/src/Symfony/Framework/ClassCollectionLoader.php +++ b/src/Symfony/Framework/ClassCollectionLoader.php @@ -18,11 +18,20 @@ */ class ClassCollectionLoader { + static protected $loaded; + /** * @throws \InvalidArgumentException When class can't be loaded */ static public function load($classes, $cacheDir, $name, $autoReload) { + // each $name can only be loaded once per PHP process + if (isset(self::$loaded[$name])) { + return; + } + + self::$loaded[$name] = true; + $classes = array_unique($classes); $cache = $cacheDir.'/'.$name.'.php'; diff --git a/src/Symfony/Framework/Kernel.php b/src/Symfony/Framework/Kernel.php index 406cfe44dc59..0298db8362d7 100644 --- a/src/Symfony/Framework/Kernel.php +++ b/src/Symfony/Framework/Kernel.php @@ -36,8 +36,6 @@ */ abstract class Kernel implements HttpKernelInterface, \Serializable { - static protected $loaded; - protected $bundles; protected $bundleDirs; protected $container; @@ -127,17 +125,12 @@ public function boot() $this->container = $this->initializeContainer(); // load core classes - // can only be loaded once (for all Kernel in the same process) - if (!self::$loaded) { - self::$loaded = true; - - ClassCollectionLoader::load( - $this->container->getParameter('kernel.compiled_classes'), - $this->container->getParameter('kernel.cache_dir'), - 'classes', - $this->container->getParameter('kernel.debug') - ); - } + ClassCollectionLoader::load( + $this->container->getParameter('kernel.compiled_classes'), + $this->container->getParameter('kernel.cache_dir'), + 'classes', + $this->container->getParameter('kernel.debug') + ); foreach ($this->bundles as $bundle) { $bundle->setContainer($this->container);