8000 [HttpKernel] fix Kernel name when stored in a directory starting with a number by fabpot · Pull Request #21883 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] fix Kernel name when stored in a directory starting with a number #21883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files. < 8000 /div>
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ public function getName()
{
if (null === $this->name) {
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
if (ctype_digit($this->name[0])) {
$this->name = '_'.$this->name;
}
}

return $this->name;
Expand Down
37 changes: 37 additions & 0 deletions src/Symfony/Component/HttpKernel/Tests/Fixtures/123/Kernel123.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\Tests\Fixtures\_123;

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class Kernel123 extends Kernel
{
public function registerBundles()
{
return array();
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
}

public function getCacheDir()
{
return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/cache/'.$this->environment;
}

public function getLogDir()
{
return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/logs';
}
}
8 changes: 8 additions & 0 deletions src/Symfony/Component/HttpKernel/Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,14 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
$kernel->terminate(Request::create('/'), new Response());
}

public function testKernelRootDirNameStartingWithANumber()
{
$dir = __DIR__.'/Fixtures/123';
require_once $dir.'/Kernel123.php';
$kernel = new \Symfony\Component\HttpKernel\Tests\Fixtures\_123\Kernel123('dev', true);
$this->assertEquals('_123', $kernel->getName());
}

/**
* Returns a mock for the BundleInterface.
*
Expand Down
0