8000 Snapshot declared classes early & fix class cache warmup · symfony/symfony@c552185 · GitHub
[go: up one dir, main page]

Skip to content

Commit c552185

Browse files
Snapshot declared classes early & fix class cache warmup
1 parent f15289f commit c552185

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ClassCacheCacheWarmer.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\ClassLoader\ClassCollectionLoader;
1515
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
16+
use Symfony\Component\HttpKernel\Kernel;
1617

1718
/**
1819
* Generates the Class Cache (classes.php) file.
@@ -21,6 +22,15 @@
2122
*/
2223
class ClassCacheCacheWarmer implements CacheWarmerInterface
2324
{
25+
private $declaredClasses = false;
26+
27+
public function __construct(Kernel $kernel = null)
28+
{
29+
if (null !== $kernel) {
30+
$this->declaredClasses = $kernel->declaredClasses;
31+
}
32+
}
33+
2434
/**
2535
* Warms up the cache.
2636
*
@@ -38,7 +48,7 @@ public function warmUp($cacheDir)
3848
return;
3949
}
4050

41-
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', false);
51+
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', false, $this->declaredClasses);
4252
}
4353

4454
/**

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
131131
$realKernelClass = substr($realKernelClass, $pos + 1);
132132
}
133133
$tempKernel = $this->getTempKernel($realKernel, $namespace, $realKernelClass, $warmupDir);
134+
$tempKernel->declaredClasses = $realKernel->declaredClasses;
134135
$tempKernel->boot();
135136

136137
$tempKernelReflection = new \ReflectionObject($tempKernel);

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
<service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer">
2626
<tag name="kernel.cache_warmer" />
27+
<argument type="service" id="kernel" />
2728
</service>
2829

2930
<service id="cache_clearer" class="Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer">

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
"php": ">=5.5.9",
2020
"symfony/asset": "~2.8|~3.0",
2121
"symfony/cache": "~3.1",
22-
"symfony/class-loader": "~2.8|~3.0",
22+
"symfony/class-loader": "~3.2",
2323
"symfony/dependency-injection": "~3.2",
2424
"symfony/config": "~2.8|~3.0",
2525
"symfony/event-dispatcher": "~2.8|~3.0",
2626
"symfony/http-foundation": "~3.1",
27-
"symfony/http-kernel": "~3.1.2|~3.2",
27+
"symfony/http-kernel": "~3.2",
2828
"symfony/polyfill-mbstring": "~1.0",
2929
"symfony/filesystem": "~2.8|~3.0",
3030
"symfony/finder": "~2.8|~3.0",

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface
6969
const END_OF_MAINTENANCE = '07/2017';
7070
const END_OF_LIFE = '01/2018';
7171

72+
/**
73+
* @internal
74+
*/
75+
public $declaredClasses;
76+
7277
/**
7378
* Constructor.
7479
*
@@ -77,6 +82,8 @@ abstract class Kernel implements KernelInterface, TerminableInterface
7782
*/
7883
public function __construct($environment, $debug)
7984
{
85+
$this->declaredClasses = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
86+
8087
$this->environment = $environment;
8188
$this->debug = (bool) $debug;
8289
$this->rootDir = $this->getRootDir();
@@ -379,7 +386,7 @@ public function getCharset()
379386
protected function doLoadClassCache($name, $extension)
380387
{
381388
if (!$this->booted && is_file($this->getCacheDir().'/classes.map')) {
382-
ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension);
389+
ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, $this->declaredClasses, $extension);
383390
}
384391
}
385392

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"require-dev": {
2626
"symfony/browser-kit": "~2.8|~3.0",
27-
"symfony/class-loader": "~2.8|~3.0",
27+
"symfony/class-loader": "~3.2",
2828
"symfony/config": "~2.8|~3.0",
2929
"symfony/console": "~2.8|~3.0",
3030
"symfony/css-selector": "~2.8|~3.0",
@@ -40,7 +40,8 @@
4040
"symfony/var-dumper": "~2.8|~3.0"
4141
},
4242
"conflict": {
43-
"symfony/config": "<2.8"
43+
"symfony/config": "<2.8",
44+
"symfony/class-loader": "<3.2"
4445
},
4546
"suggest": {
4647
"symfony/browser-kit": "",

0 commit comments

Comments
 (0)
0