Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 887af35

Browse files
committed
minor #29032 [HttpKernel] Fix BC break in Kernel name (jvasseur)
This PR was merged into the 4.2-dev branch. Discussion ---------- [HttpKernel] Fix BC break in Kernel name | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Fix a BC break introduced by #28810 where the name of the kernel where change form the name of the folder containing the kernel class to the name of the folder containing the project. This introduced a bug with deployment processes where the cache warmup is done before moving the application to a folder with a different name and removing the possibility to compile the container (either by moving to a read-only filesystem or by removing the config directory). Commits ------- 872a772 Fix BC break in Kernel name
2 parents 8539649 + 872a772 commit 887af35

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function getName(/* $triggerDeprecation = true */)
286286
}
287287

288288
if (null === $this->name) {
289-
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->getProjectDir()));
289+
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
290290
if (ctype_digit($this->name[0])) {
291291
$this->name = '_'.$this->name;
292292
}

src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testInitializeContainerClearsOldContainers()
7575
$kernel->boot();
7676

7777
$containerDir = __DIR__.'/Fixtures/var/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
78-
$this->assertTrue(unlink(__DIR__.'/Fixtures/var/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
78+
$this->assertTrue(unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
7979
$this->assertFileExists($containerDir);
8080
$this->assertFileNotExists($containerDir.'.legacy');
8181

@@ -312,7 +312,7 @@ public function testGetName()
312312
{
313313
$kernel = new KernelForTest('test', true);
314314

315-
$this->assertEquals('HttpKernel', $kernel->getName());
315+
$this->assertEquals('Fixtures', $kernel->getName());
316316
}
317317

318318
/**
@@ -533,14 +533,14 @@ public function testKernelReset()
533533

534534
$containerClass = \get_class($kernel->getContainer());
535535
$containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
536-
unlink(__DIR__.'/Fixtures/var/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
536+
unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
537537

538538
$kernel = new CustomProjectDirKernel();
539539
$kernel->boot();
540540

541541
$this->assertInstanceOf($containerClass, $kernel->getContainer());
542542
$this->assertFileExists($containerFile);
543-
unlink(__DIR__.'/Fixtures/var/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
543+
unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
544544

545545
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
546546
$kernel->boot();

0 commit comments

Comments
 (0)