[FrameworkBundle] [HttpKernel] fixed correct EOL and EOM month

* Added a hardcoded day 01 in order to output the proper month November
which is the correct EOL and EOM month.
* \DateTime::createFromFormat('mY') will output December for every month
where day 31 exists.
This commit is contained in:
Eric Schildkamp 2019-10-31 16:27:14 +01:00 committed by Fabien Potencier
parent 85bcd9d554
commit 613717d71f
2 changed files with 5 additions and 5 deletions

View File

@ -123,7 +123,7 @@ EOT
private static function isExpired($date) private static function isExpired($date)
{ {
$date = \DateTime::createFromFormat('m/Y', $date); $date = \DateTime::createFromFormat('d/m/Y', '01/'.$date);
return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59'); return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59');
} }

View File

@ -81,8 +81,8 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
$this->data['symfony_state'] = $this->determineSymfonyState(); $this->data['symfony_state'] = $this->determineSymfonyState();
$this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION); $this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
$eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE); $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
$eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE); $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
$this->data['symfony_eom'] = $eom->format('F Y'); $this->data['symfony_eom'] = $eom->format('F Y');
$this->data['symfony_eol'] = $eol->format('F Y'); $this->data['symfony_eol'] = $eol->format('F Y');
} }
@ -314,8 +314,8 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
private function determineSymfonyState() private function determineSymfonyState()
{ {
$now = new \DateTime(); $now = new \DateTime();
$eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE)->modify('last day of this month'); $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
$eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE)->modify('last day of this month'); $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->modify('last day of this month');
if ($now > $eol) { if ($now > $eol) {
$versionState = 'eol'; $versionState = 'eol';