Feature #87935
closedUse $_SERVER['REQUEST_TIME'] instead of time() for the current time in viewhelper f:date.format()
100%
Description
The Viewhelper f:date.format() use the time()-function, of PHP to get the current time.
$base = $arguments['base'] ?? time();
This line should be replaced by
$base = $arguments['base'] ?? $_SERVER['REQUEST_TIME'];
Reason:
$_SERVER['REQUEST_TIME'] contains the starttime of the request. Every call of a Dateviewhelper will use the same 'current time'.
If a user request a website at near midnight, two calls of time() can worstly generate two different dates with the f:format.date() viewhelper.
Updated by Georg Ringer over 5 years ago
- Status changed from New to Rejected
I opened an issue in fluid project https://github.com/TYPO3/Fluid/issues/441 and therefore closed it here
Updated by Claus Due over 5 years ago
- Status changed from Rejected to New
Reopened, f:format.date is part of TYPO3 CMS so this issue was placed correctly.
Updated by Markus Pircher over 5 years ago
How often will this happen that a page is called just a few milliseconds before midnight?
Updated by Dieter Porth over 5 years ago
The Question is not, how often can this happen. The question is:
Do we want use different timestamps in views for a request?
But my idea has a disadvantage.
What will happen, if a cron-job will call a view-helper. The cronjob has no web-context. I think the correct line must be.
$base = $arguments['base'] ?? ($_SERVER['REQUEST_TIME'] ?? time());
Updated by Jonas Schwabe over 5 years ago
From my point of view $GLOBALS['SIM_EXEC_TIME'] should be used in TYPO3 8 and the DateTimeAspect should be used in TYPO3 9 instad of $_SERVER['REQUEST_TIME'] as it is initialized once and can be changed using the adminpanel date / time simulation feature which could actually be helpful.
Additionally this is also available when called from the command line because $GLOBALS['EXEC_TIME'] is initialized using time().
Updated by Dieter Porth over 5 years ago
@Jonas
Your hint is good. The argument is important to allow the change of a test-date by the adminpanel.
But the Idea got a problem. FLUID is not only part of TYPO3. Fluid is a standalone framework too. The viewhelper should not depend strictly on TYPO3.
The viewhelper may need a definition-cascade.
if (isset($arguments['base'])) { $base = $arguments['base'] // Argument of the viewhelper } else if( class_exists(TYPO3\CMS\Core\Context\Context::class) ) { // if TYPO3\CMS\Core\Context\Context exist, the TYPO3-Class TYPO3\CMS\Core\Utility\ should exist. /** @var Context $context */ $context = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Core\Context::class); $base = $context->getPropertyFromAspect('date', 'timestamp'); // TYPO3 9++ } else if( isset($GLOBALS['SIM_EXEC_TIME']) ) { $base = $GLOBALS['SIM_EXEC_TIME']; // TYPO3 8.7 } else { $base = ($_SERVER['REQUEST_TIME'] ?? time()); }
Updated by Gerrit Code Review over 5 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Gerrit Code Review over 5 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60454
Updated by Benni Mack over 5 years ago
- Related to Bug #82491: FluidStyledContent Header/Date.html Partial should respect config.locale_all typoscript setting for date format frontend output added
Updated by Gerrit Code Review over 5 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60584
Updated by Benni Mack over 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8c26d46ebe3324467c461ba76aaf02a3c5ee6617.