소스 검색

[HttpKernel] changed the way compiled classes are managed to be sure that they are included before the Kernel is booted

If not, as classes can be loaded during the boot, there is no way to be sure that
a class will not be already loaded by a third party bundle.

If the Kernel is already booted, we don't included the compiled classes.
Fabien Potencier 14 년 전
부모
커밋
e16c226a5c
1개의 변경된 파일4개의 추가작업 그리고 6개의 파일을 삭제
  1. 4 6
      src/Symfony/Component/HttpKernel/Kernel.php

+ 4 - 6
src/Symfony/Component/HttpKernel/Kernel.php

@@ -397,12 +397,8 @@ abstract class Kernel implements KernelInterface
      */
     public function loadClassCache($name = 'classes', $extension = '.php')
     {
-        if (!$this->booted) {
-            $this->boot();
-        }
-
-        if ($this->container->hasParameter('kernel.compiled_classes')) {
-            ClassCollectionLoader::load($this->container->getParameter('kernel.compiled_classes'), $this->getCacheDir(), $name, $this->debug, false, $extension);
+        if (!$this->booted && file_exists($this->getCacheDir().'/classes.map')) {
+            ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension);
         }
     }
 
@@ -645,6 +641,8 @@ abstract class Kernel implements KernelInterface
         $container->addCompilerPass(new AddClassesToCachePass($this));
         $container->compile();
 
+        file_put_contents($this->getCacheDir().'/classes.map', sprintf('<?php return %s;', var_export($container->getParameter('kernel.compiled_classes'), true)));
+
         return $container;
     }