Project

General

Profile

Actions

Bug #103669

closed

Backend Preview of "planned" pages throw 503 on PHP 8.2

Added by Johannes Rebhan 2 months ago. Updated 2 months ago.

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.


Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #103588: PreviewSimulator for time restricted pagesResolved2024-04-10

Actions
Actions #1

Updated by Johannes Rebhan 2 months 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;
    }
Actions #2

Updated by Georg Ringer 2 months ago

  • Is duplicate of Bug #103588: PreviewSimulator for time restricted pages added
Actions #3

Updated by Georg Ringer 2 months 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

Also available in: Atom PDF