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

Commita863e2f

Browse files
committed
bug#40535 [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel (topikito)
This PR was squashed before being merged into the 4.4 branch.Discussion----------[HttpKernel] ConfigDataCollector to return known data without the need of a Kernel| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#40534| License | MIT| Doc PR |Sets `$this->data` with information that can be known without the need of a `Kernel`.Commits-------d919f2c [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel
2 parents16f3fc1 +d919f2c commita863e2f

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

‎src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ public function setKernel(KernelInterface $kernel = null)
5959
*/
6060
publicfunctioncollect(Request$request,Response$response/*, \Throwable $exception = null*/)
6161
{
62+
$eom = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_MAINTENANCE);
63+
$eol = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_LIFE);
64+
6265
$this->data = [
6366
'app_name' =>$this->name,
6467
'app_version' =>$this->version,
6568
'token' =>$response->headers->get('X-Debug-Token'),
6669
'symfony_version' => Kernel::VERSION,
67-
'symfony_state' =>'unknown',
70+
'symfony_minor_version' =>sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION),
71+
'symfony_lts' =>4 === Kernel::MINOR_VERSION,
72+
'symfony_state' =>$this->determineSymfonyState(),
73+
'symfony_eom' =>$eom->format('F Y'),
74+
'symfony_eol' =>$eol->format('F Y'),
6875
'env' =>isset($this->kernel) ?$this->kernel->getEnvironment() :'n/a',
6976
'debug' =>isset($this->kernel) ?$this->kernel->isDebug() :'n/a',
7077
'php_version' => \PHP_VERSION,
@@ -82,14 +89,6 @@ public function collect(Request $request, Response $response/*, \Throwable $exce
8289
foreach ($this->kernel->getBundles()as$name =>$bundle) {
8390
$this->data['bundles'][$name] =newClassStub(\get_class($bundle));
8491
}
85-
86-
$this->data['symfony_state'] =$this->determineSymfonyState();
87-
$this->data['symfony_minor_version'] =sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
88-
$this->data['symfony_lts'] =4 === Kernel::MINOR_VERSION;
89-
$eom = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_MAINTENANCE);
90-
$eol = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_LIFE);
91-
$this->data['symfony_eom'] =$eom->format('F Y');
92-
$this->data['symfony_eol'] =$eol->format('F Y');
9392
}
9493

9594
if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~',$this->data['php_version'],$matches) &&isset($matches[2])) {

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public function testCollect()
4141
$this->assertSame(\extension_loaded('xdebug'),$c->hasXDebug());
4242
$this->assertSame(\extension_loaded('Zend OPcache') &&filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN),$c->hasZendOpcache());
4343
$this->assertSame(\extension_loaded('apcu') &&filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN),$c->hasApcu());
44+
$this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION),$c->getSymfonyMinorVersion());
45+
$this->assertContains($c->getSymfonyState(), ['eol','eom','dev','stable']);
46+
47+
$eom = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_MAINTENANCE)->format('F Y');
48+
$eol = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_LIFE)->format('F Y');
49+
$this->assertSame($eom,$c->getSymfonyEom());
50+
$this->assertSame($eol,$c->getSymfonyEol());
4451
}
4552

4653
/**
@@ -58,6 +65,34 @@ public function testLegacy()
5865
$this->assertSame('name',$c->getApplicationName());
5966
$this->assertNull($c->getApplicationVersion());
6067
}
68+
69+
publicfunctiontestCollectWithoutKernel()
70+
{
71+
$c =newConfigDataCollector();
72+
$c->collect(newRequest(),newResponse());
73+
74+
$this->assertSame('n/a',$c->getEnv());
75+
$this->assertSame('n/a',$c->isDebug());
76+
$this->assertSame('config',$c->getName());
77+
$this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(),'~').'~', \PHP_VERSION);
78+
$this->assertMatchesRegularExpression('~'.preg_quote((string)$c->getPhpVersionExtra(),'~').'$~', \PHP_VERSION);
79+
$this->assertSame(\PHP_INT_SIZE *8,$c->getPhpArchitecture());
80+
$this->assertSame(class_exists(\Locale::class,false) && \Locale::getDefault() ? \Locale::getDefault() :'n/a',$c->getPhpIntlLocale());
81+
$this->assertSame(date_default_timezone_get(),$c->getPhpTimezone());
82+
$this->assertSame(Kernel::VERSION,$c->getSymfonyVersion());
83+
$this->assertSame(4 === Kernel::MINOR_VERSION,$c->isSymfonyLts());
84+
$this->assertNull($c->getToken());
85+
$this->assertSame(\extension_loaded('xdebug'),$c->hasXDebug());
86+
$this->assertSame(\extension_loaded('Zend OPcache') &&filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN),$c->hasZendOpcache());
87+
$this->assertSame(\extension_loaded('apcu') &&filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN),$c->hasApcu());
88+
$this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION),$c->getSymfonyMinorVersion());
89+
$this->assertContains($c->getSymfonyState(), ['eol','eom','dev','stable']);
90+
91+
$eom = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_MAINTENANCE)->format('F Y');
92+
$eol = \DateTime::createFromFormat('d/m/Y','01/'.Kernel::END_OF_LIFE)->format('F Y');
93+
$this->assertSame($eom,$c->getSymfonyEom());
94+
$this->assertSame($eol,$c->getSymfonyEol());
95+
}
6196
}
6297

6398
class KernelForTestextends Kernel

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp