From dae3aeb00104906b5c6189568a37dd1c402baf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech> Date: Sun, 28 Nov 2021 21:01:47 +0100 Subject: [PATCH] [BUGFIX] Tighten CleanerTaskTest setup for changed PHP 8.1 behaviour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CleanerTaskTest dynamically calculates the needed 'period' time to use for testing, if one page records will survive the cleaning task, as not being outside this periode grace time. This has worked quite some time, but may crash now in a quite narrow timeframe, which failed core ci tests, if they were run in this timeframe - and made it reproducible only for a night owl, as the timeframe lays between UTC '00:00-01:00'. PHP8.1.0RC6 included a regression bugfix which introduced another bug, which leads to inconsinstent calculation behaviour for using 'diff()' method of '\DateTime' or '\DateTimeImmutable', if timezone switches are needed and there are the first hour leap (or two hour in summer time). This is already fixed in PHP8.1.0 release. As we do not really need that 1 hour leap calculation here, we are able to tighten the test setup here and calculate the needed dynamic period in way to work around this bug for PHP8.1.0RC6, be backwards compatible and also being safe for 8.1.0 release. PHP regression fix introduced new bug (8.1.0RC6): https://github.com/php/php-src/commit/904933e9185664148ce54 PHP bugfix released with 8.1.0: https://github.com/php/php-src/commit/e4679ef0c2d5a0a81cb6e This patch uses '00:00:00' for the time part of both dates and further uses 'UTC' timezone enforcement to calculate the period time, which stabilizes this testcase and lets night owls do their stuff undisturbed. Resolves: #96128 Releases: master, 11.5 Change-Id: Ib1f4201ce8556ae8f22eeb4463732c62394e3c14 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72346 Reviewed-by: Stephan Großberndt <stephan.grossberndt@typo3.org> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../recycler/Tests/Functional/Task/Pages/CleanerTaskTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/recycler/Tests/Functional/Task/Pages/CleanerTaskTest.php b/typo3/sysext/recycler/Tests/Functional/Task/Pages/CleanerTaskTest.php index 0f60deccf376..cc4b9c90100d 100644 --- a/typo3/sysext/recycler/Tests/Functional/Task/Pages/CleanerTaskTest.php +++ b/typo3/sysext/recycler/Tests/Functional/Task/Pages/CleanerTaskTest.php @@ -48,11 +48,12 @@ class CleanerTaskTest extends FunctionalTestCase $this->importCSVDataSet(__DIR__ . '/DataSet/Fixtures/pages.csv'); $subject = new CleanerTask(); $subject->setTcaTables(['pages']); + $utcTimeZone = new \DateTimeZone('UTC'); // this is when the test was created. One of the fixtures (uid 4) has this date - $creationDate = date_create_immutable_from_format('d.m.Y', '28.09.2020')->setTime(0, 0, 0); + $creationDate = date_create_immutable_from_format('Y-m-d H:i:s', '2020-09-28 00:00:00', $utcTimeZone); // we want to set the period in a way that older records get deleted, but not the one created today - $difference = $creationDate->diff(new \DateTime(), true); + $difference = $creationDate->diff(new \DateTime('today', $utcTimeZone), true); // let's set the amount of days one higher than the reference date $period = (int)$difference->format('%a') + 1; $subject->setPeriod($period); -- GitLab