Actions
Bug #103669
closedBackend Preview of "planned" pages throw 503 on PHP 8.2
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
AdminPanel
Target version:
-
Start date:
2024-04-18
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:
Description
It seems like this piece of code in the PreviewSimulator is not "precise" enough for PHP 8.2 and throws a 503 if you try to preview a page from the backend, that has a start date in the future:
protected function simulateDate(ServerRequestInterface $request): bool
{
$queryTime = $request->getQueryParams()['ADMCMD_simTime'] ?? false;
if (!$queryTime) {
return false;
}
$GLOBALS['SIM_EXEC_TIME'] = $queryTime;
$GLOBALS['SIM_ACCESS_TIME'] = $queryTime - $queryTime % 60;
$this->context->setAspect(
'date',
GeneralUtility::makeInstance(
DateTimeAspect::class,
(new \DateTimeImmutable())->setTimestamp($queryTime)
)
);
return true;
}
DateTimeImmutable::setTimestamp(): Argument #1 ($timestamp) must be of type int, string given
Suggest to add a typecast early on to convert $queryTime string to the int it actually is.
Updated by Johannes Rebhan 16 days ago
Something like that maybe?
protected function simulateDate(ServerRequestInterface $request): bool
{
$params = $request->getQueryParams();
if(!isset($params['ADMCMD_simTime'])){
return false;
}
$queryTime = (int)$params['ADMCMD_simTime'];
$simulatedDate = new \DateTimeImmutable('@' . $queryTime);
if (!$simulatedDate) {
return false;
}
$GLOBALS['SIM_EXEC_TIME'] = $queryTime;
$GLOBALS['SIM_ACCESS_TIME'] = $queryTime - $queryTime % 60;
$this->context->setAspect(
'date',
GeneralUtility::makeInstance(
DateTimeAspect::class,
$simulatedDate
)
);
return true;
}
Updated by Georg Ringer 15 days ago
- Is duplicate of Bug #103588: PreviewSimulator for time restricted pages added
Updated by Georg Ringer 15 days ago
- Status changed from New to Closed
- Tags deleted (
type)
thanks for creating the issue. this has been solved with #103588 - therefore closing this issue as duplicate
Actions