Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc25f9a

Browse files
committed
bug#24824 [FrameworkBundle][Config] fix: do not add resource checkers for no-debug (dmaicher)
This PR was merged into the 3.4 branch.Discussion----------[FrameworkBundle][Config] fix: do not add resource checkers for no-debug| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#24808| License | MIT| Doc PR | -As mentioned within#24808 replacing the `ConfigCachePass` here537c496...a442e37#diff-687bdbb38a4dc672ca2a79f23e764892L127 with a tagged iterator argument resulted in resource checkers being added even if debug=false.This resulted in a performance drop as on every request all the checkers have been checked.This restores the previous behavior and does not add any checkers if debug=false.Commits-------645f712 [FrameworkBundle][Config] fix: do not add resource checkers for debug=false
2 parentse973c24 +645f712 commitdc25f9a

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ public function load(array $configs, ContainerBuilder $container)
361361
$container->registerForAutoconfiguration(ObjectInitializerInterface::class)
362362
->addTag('validator.initializer');
363363

364+
if (!$container->getParameter('kernel.debug')) {
365+
// remove tagged iterator argument for resource checkers
366+
$container->getDefinition('config_cache_factory')->setArguments(array());
367+
}
368+
364369
if (\PHP_VERSION_ID <70000) {
365370
$this->addClassesToCompile(array(
366371
'Symfony\\Component\\Config\\ConfigCache',

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,17 @@ public function testCachePoolServices()
988988
$this->assertCachePoolServiceDefinitionIsCreated($container,'cache.def','cache.app',11);
989989
}
990990

991+
publicfunctiontestRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug()
992+
{
993+
$container =$this->createContainer(array('kernel.debug' =>true));
994+
(newFrameworkExtension())->load(array(),$container);
995+
$this->assertCount(1,$container->getDefinition('config_cache_factory')->getArguments());
996+
997+
$container =$this->createContainer(array('kernel.debug' =>false));
998+
(newFrameworkExtension())->load(array(),$container);
999+
$this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments());
1000+
}
1001+
9911002
protectedfunctioncreateContainer(array$data =array())
9921003
{
9931004
returnnewContainerBuilder(newParameterBag(array_merge(array(

‎src/Symfony/Component/Config/ResourceCheckerConfigCache.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ public function isFresh()
6868
returnfalse;
6969
}
7070

71-
if (!$this->resourceCheckers) {
71+
if ($this->resourceCheckersinstanceof \Traversable && !$this->resourceCheckersinstanceof \Countable) {
72+
$this->resourceCheckers =iterator_to_array($this->resourceCheckers);
73+
}
74+
75+
if (!count($this->resourceCheckers)) {
7276
returntrue;// shortcut - if we don't have any checkers we don't need to bother with the meta file at all
7377
}
7478

‎src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,20 @@ public function testCacheIsNotFreshIfEmpty()
5757
$this->assertFalse($cache->isFresh());
5858
}
5959

60-
publicfunctiontestCacheIsFreshIfNocheckerProvided()
60+
publicfunctiontestCacheIsFreshIfNoCheckerProvided()
6161
{
6262
/* For example in prod mode, you may choose not to run any checkers
6363
at all. In that case, the cache should always be considered fresh. */
6464
$cache =newResourceCheckerConfigCache($this->cacheFile);
6565
$this->assertTrue($cache->isFresh());
6666
}
6767

68+
publicfunctiontestCacheIsFreshIfEmptyCheckerIteratorProvided()
69+
{
70+
$cache =newResourceCheckerConfigCache($this->cacheFile,new \ArrayIterator(array()));
71+
$this->assertTrue($cache->isFresh());
72+
}
73+
6874
publicfunctiontestResourcesWithoutcheckersAreIgnoredAndConsideredFresh()
6975
{
7076
/* As in the previous test, but this time we have a resource. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp