Skip to content

Commit f8e2aa2

Browse files
bug #51588 [FrameworkBundle] Always use buildDir as ConfigBuilderGenerator outputDir (HypeMC)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Always use buildDir as `ConfigBuilderGenerator` outputDir | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #51582 | License | MIT | Doc PR | - The `ConfigBuilderGenerator` is instantiated in three places, two of which use `kernel.build_dir` as the output dir, and one which uses `kernel.cache_dir`: - https://github.com/symfony/symfony/blob/29f427fcbd78b700a1b253c7927e51017d964f59/src/Symfony/Component/HttpKernel/Kernel.php#L736 - https://github.com/symfony/symfony/blob/29f427fcbd78b700a1b253c7927e51017d964f59/src/Symfony/Component/DependencyInjection/Extension/ExtensionTrait.php#L55-L61 - https://github.com/symfony/symfony/blob/29f427fcbd78b700a1b253c7927e51017d964f59/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php#L43-L45 This PR fixes this inconsistency so that `kernel.build_dir` is always used. Commits ------- e1a14b7 [FrameworkBundle] Always use buildDir as `ConfigBuilderGenerator` outputDir
2 parents aa56d07 + e1a14b7 commit f8e2aa2

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(KernelInterface $kernel, LoggerInterface $logger = n
4444
*/
4545
public function warmUp(string $cacheDir)
4646
{
47-
$generator = new ConfigBuilderGenerator($cacheDir);
47+
$generator = new ConfigBuilderGenerator($this->kernel->getBuildDir());
4848

4949
foreach ($this->kernel->getBundles() as $bundle) {
5050
$extension = $bundle->getContainerExtension();
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
13+
14+
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer;
15+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
16+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
17+
use Symfony\Component\Config\Loader\LoaderInterface;
18+
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpKernel\Kernel;
20+
21+
class ConfigBuilderCacheWarmerTest extends TestCase
22+
{
23+
private $varDir;
24+
25+
protected function setUp(): void
26+
{
27+
$this->varDir = sys_get_temp_dir().'/'.uniqid();
28+
$fs = new Filesystem();
29+
$fs->mkdir($this->varDir);
30+
}
31+
32+
protected function tearDown(): void
33+
{
34+
$fs = new Filesystem();
35+
$fs->remove($this->varDir);
36+
unset($this->varDir);
37+
}
38+
39+
public function testBuildDirIsUsedAsConfigBuilderOutputDir()
40+
{
41+
$kernel = new class($this->varDir) extends Kernel {
42+
private $varDir;
43+
44+
public function __construct(string $varDir)
45+
{
46+
parent::__construct('test', false);
47+
48+
$this->varDir = $varDir;
49+
}
50+
51+
public function registerBundles(): iterable
52+
{
53+
yield new FrameworkBundle();
54+
}
55+
56+
public function getBuildDir(): string
57+
{
58+
return $this->varDir.'/build';
59+
}
60+
61+
public function getCacheDir(): string
62+
{
63+
return $this->varDir.'/cache';
64+
}
65+
66+
public function registerContainerConfiguration(LoaderInterface $loader)
67+
{
68+
}
69+
};
70+
$kernel->boot();
71+
72+
$warmer = new ConfigBuilderCacheWarmer($kernel);
73+
$warmer->warmUp($kernel->getCacheDir());
74+
75+
self::assertDirectoryExists($kernel->getBuildDir().'/Symfony');
76+
self::assertDirectoryDoesNotExist($kernel->getCacheDir().'/Symfony');
77+
}
78+
}

0 commit comments

Comments
 (0)
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