77505[BUGFIX] Handle getPage_noCheck properly
Commit message
Review
-
Code review CR +2 Done
- Stefan Bürk +2
- Benni Mack +1
-
Verified V +2 Done
- Stefan Bürk +2
- Benni Mack +1
- core-ci +1 CI
Issues 1
Files 1
Review log 2532
Show 47 earlier messages
-
Thomas Hohn uploaded patch set 1 01/19/23, 14:32
-
core-ci voted on patch set 1 V +1 01/19/23, 14:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36256
-
Thomas Hohn uploaded patch set 2
V +101/19/23, 16:09 -
Benni Mack commented on patch set 3 01/19/23, 16:10
Published edit on patch set 2. -
core-ci voted on patch set 2 V +1 01/19/23, 16:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36266
-
core-ci voted on patch set 3 V +1 01/19/23, 17:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36279
-
Georg Ringer voted on patch set 3 V +1 CR +1 01/20/23, 06:38
-
Anja Leichsenring voted on patch set 3 CR +1 01/20/23, 11:56
-
Claus Due commented on patch set 3 CR -1 01/22/23, 20:32
Aside from the comments in diff, functionality change itself looks good to me and use case is acknowledged! I would however at least request that the redundant is_array() is removed.TypoScriptFrontendController.php:810is_array() seems redundant since === [] would return false if candidate is not an array.TypoScriptFrontendController.php:812Should this also have a try ... catch (PageNotFoundException $e) like in the block below (comment // If still no page...)? IMHO it doesn't appear to be necessary but it might make debugging easier if there is an explicit exception code when this particular call to pageNotFoundAction() yields a page not found exception. I defer to core mergers' opinion on this.TypoScriptFrontendController.php:820The added parenthesis around $rawPageRecord[$hiddenField] is redundant. It might however make sense to null coalesce this to ?? false; or even throw a different exception indicating that if $rawPageRecord does not contain the column $hiddenField it is most likely an error in TCA. -
Thomas Hohn uploaded patch set 4
CR +1V +101/23/23, 06:28 -
Thomas Hohn commented on patch set 4 01/23/23, 06:30
TypoScriptFrontendController.php:810ReplyPoint taken ;-)TypoScriptFrontendController.php:820ReplyThe getPage_noCheck returns either a full page array or [] - so it should not be necessary -
core-ci voted on patch set 4 V +1 01/23/23, 06:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36453
-
Stefan Bürk commented on patch set 4 01/23/23, 21:49
TypoScriptFrontendController.php:812ReplyAgree on this. We should wrap this in a `try{} catch() {}` with catching `PageNotFoundException` and rethrowing it with a dedicated errorcode similar below (L848-857) -
Thomas Hohn uploaded patch set 5
V +101/24/23, 05:58 -
Thomas Hohn commented on patch set 5 01/24/23, 06:00
TypoScriptFrontendController.php:812ReplyAdded a try() catch() {} block as requested -
core-ci voted on patch set 5 V +1 01/24/23, 06:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36507
-
Oliver Klee updated the commit message in patch set 6
V +101/24/23, 08:56 -
core-ci voted on patch set 6 V +1 01/24/23, 09:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36515
-
Thomas Hohn commented on patch set 6 02/01/23, 14:22
Maybe you could have a look at this one lolli? -
Christian Kuhn commented on patch set 6 02/01/23, 14:27
had a look already, didn't understand full impact, came to the conclusion i can't decide quickly, and put on hold to me again ;) will try to give it another shot if nobody is quicker with more knowledge on impact. -
Markus Klein commented on patch set 6 CR +1 02/13/23, 21:21
Makes sense to me, but do you have a hint for me on how to test this? -
Thomas Hohn commented on patch set 6 02/14/23, 14:53
Reply
Hi Markus. So we have the headless extension installed. So the cases happens when the API endpoint is called for a page that doesn't exists. So a call to: https://exo11.hest.ninja/api/?id=1234 Will fail since there is no page with id 1234. Please note that you shouldn't have a backend session since the code in the TyposcriptController will be bypassed. "Normal" page generation will yield a page not found page. When I look at the middleware configuration and the stacktrace - it also indicates that the headless stuff isn't invoked at this point - so I think it's some "kind" of race condition. The Middleware config looks like: typo3/cms-frontend/timetracker = TYPO3\CMS\Frontend\Middleware\TimeTrackerInitialization typo3/cms-core/verify-host-header = TYPO3\CMS\Core\Middleware\VerifyHostHeader typo3/cms-core/normalized-params-attribute = TYPO3\CMS\Core\Middleware\NormalizedParamsAttribute beechit/eid-frontend/authentication = BeechIt\FalSecuredownload\Middleware\EidFrontendAuthentication systime/sytime_common_php/systime-maintenance-mode = SYSTIME\SystimeCommonPhp\Frontend\Middleware\SystimeMaintenanceMode typo3/cms-frontend/site = TYPO3\CMS\Frontend\Middleware\SiteResolver typo3/cms-frontend/maintenance-mode = TYPO3\CMS\Frontend\Middleware\MaintenanceMode typo3/cms-frontend/backend-user-authentication = TYPO3\CMS\Frontend\Middleware\BackendUserAuthenticator typo3/cms-frontend/authentication = TYPO3\CMS\Frontend\Middleware\FrontendUserAuthenticator typo3/cms-frontend/base-redirect-resolver = TYPO3\CMS\Frontend\Middleware\SiteBaseRedirectResolver typo3/cms-frontend/static-route-resolver = TYPO3\CMS\Frontend\Middleware\StaticRouteResolver typo3/cms-frontend/page-resolver = TYPO3\CMS\Frontend\Middleware\PageResolver typo3/cms-frontend/preview-simulator = TYPO3\CMS\Frontend\Middleware\PreviewSimulator apache-solr-for-typo3/page-indexer-initialization = ApacheSolrForTypo3\Solr\Middleware\PageIndexerInitialization typo3/cms-frontend/page-argument-validator = TYPO3\CMS\Frontend\Middleware\PageArgumentValidator typo3/cms-frontend/tsfe = TYPO3\CMS\Frontend\Middleware\TypoScriptFrontendInitialization typo3/cms-frontend/eid-new = TYPO3\CMS\Frontend\Middleware\EidHandler typo3/cms-frontend/prepare-tsfe-rendering = TYPO3\CMS\Frontend\Middleware\PrepareTypoScriptFrontendRendering headless/cms-frontend/shortcut-and-mountpoint-redirect = SYSTIME\SystimeHeadlessConfig\Middleware\ShortcutAndMountPointRedirect typo3/cms-frontend/shortcut-and-mountpoint-redirect = TYPO3\CMS\Frontend\Middleware\ShortcutAndMountPointRedirect typo3/cms-frontend/content-length-headers = TYPO3\CMS\Frontend\Middleware\ContentLengthResponseHeader apache-solr-for-typo3/page-indexer-finisher = ApacheSolrForTypo3\Solr\Middleware\PageIndexerFinisher typo3/cms-frontend/output-compression = TYPO3\CMS\Frontend\Middleware\OutputCompression typo3/cms-core/response-propagation = TYPO3\CMS\Core\Middleware\ResponsePropagation fluidtypo3/vhs/asset-inclusion = FluidTYPO3\Vhs\Middleware\AssetInclusion headless/cms-frontend/prepare-user-int = FriendsOfTYPO3\Headless\Middleware\UserIntMiddleware namelessCoder/newrelicIntegration/new-relic = NamelessCoder\NewrelicIntegration\Middleware\NewRelicInstrumentation The stacktrace looks like this (removed the bootstrapping etc..) at TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'Undefined array key "hidden"', 'typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php', 1096) in typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php line 1096 $includeHiddenPages = $this->context->getPropertyFromAspect('visibility', 'includeHiddenPages') || $this->isBackendUserLoggedIn(); if (!empty($hiddenField) && !$includeHiddenPages) { // Page is "hidden" => 404 (deliberately done in default language, as this cascades to language overlays) $rawPageRecord = $this->sys_page->getPage_noCheck($this->id); $requestedPageIsHidden = (bool)$rawPageRecord[$hiddenField]; } $requestedPageRowWithoutGroupCheck = $this->sys_page->getPage($this->id, true); if (!empty($requestedPageRowWithoutGroupCheck)) { at TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->getPageAndRootline(object(TYPO3\CMS\Core\Http\ServerRequest)) in typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php line 1493 * @internal */ protected function getPageAndRootlineWithDomain($rootPageId, ServerRequestInterface $request) { $this->getPageAndRootline($request); $rootPageId = (int)$rootPageId; // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's via ?id=123 from other sites are not possible. if (is_array($this->rootLine) && $this->rootLine !== []) { $idFound = false; at TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->getPageAndRootlineWithDomain(1, object(TYPO3\CMS\Core\Http\ServerRequest)) typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php line 991 $timeTracker->push('fetch_the_id rootLine/'); // We store the originally requested id $this->requestedId = $this->id; try { $this->getPageAndRootlineWithDomain($this->site->getRootPageId(), $request); } catch (ShortcutTargetPageNotFoundException $e) { $this->pageNotFound = 1; } $timeTracker->pull(); at TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id(object(TYPO3\CMS\Core\Http\ServerRequest)) typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php line 758 if ($isPreview) { $this->disableCache(); } // Now, get the id, validate access etc: $this->fetch_the_id($request); // Check if backend user has read access to this page. If not, recalculate the id. if ($this->isBackendUserLoggedIn() && $isPreview && !$this->getBackendUser()->doesUserHaveAccess($this->page, Permission::PAGE_SHOW)) { $this->unsetBackendUser(); // Resetting at TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->determineId(object(TYPO3\CMS\Core\Http\ServerRequest)) in typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php line 97 if ($request->getAttribute('noCache', false)) { $controller->no_cache = true; } $controller->determineId($request); $request = $request->withAttribute('frontend.controller', $controller); // Make TSFE globally available // @todo deprecate $GLOBALS['TSFE'] once TSFE is retrieved from the at TYPO3\CMS\Frontend\Middleware\TypoScriptFrontendInitialization->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(Psr\Http\Server\RequestHandlerInterface@anonymoustypo3/sysext/core/Classes/Http/MiddlewareDispatcher.php:138$1951)) in typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 172 if (!$middleware instanceof MiddlewareInterface) { throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342); } return $middleware->process($request, $this->next); } }; } } at Psr\Http\Server\RequestHandlerInterface@anonymoustypo3/sysext/core/Classes/Http/MiddlewareDispatcher.php:138$1951->handle(object(TYPO3\CMS\Core\Http\ServerRequest)) in typo3/sysext/frontend/Classes/Middleware/PageArgumentValidator.php line 132 } } $request = $request->withAttribute('noCache', $this->disableCache); return $handler->handle($request); } .... -
Thomas Hohn commented on patch set 6 02/14/23, 14:54
Reply
So digged a bit deeper into the problem with https://review.typo3.org/c/Packages/TYPO3.CMS/+/77505. After digging into it - I realised that we have a custom version of matchRequest in PageRouter - it looks like: public function matchRequest(ServerRequestInterface $request, RouteResultInterface $previousResult = null): RouteResultInterface { $identifier = $request->getQueryParams()['id'] ?? 0; $requestId = (int)($identifier ?? 0); if ($requestId === 0) { $requestId = $this->site->getRootPageId(); } if ($requestId > 0) { return new PageArguments( $requestId, (string)($request->getQueryParams()['type'] ?? '0'), [], [], $request->getQueryParams() ); } } You could argue that it lacks a check for if the page id does exists. On the other hand I still believe that the core should have the check if the result of calling $this->sys_page->getPage_noCheck($this->id); is an empty array ... -
Markus Klein commented on patch set 6 02/24/23, 14:32
Reply
Yes, we should have some safety-check in the Core. No matter how unlikely it is to reach a faulty state at this point. -
Benni Mack commented on patch set 6 03/01/23, 14:40
I really would like to know how to reproduce this... usually Routing should catch this, as there won't be a page available then? -
Thomas Hohn commented on patch set 6 03/01/23, 14:44
Reply
Hi Benni - please have a look at what I wrote to Markus regarding how it happens -
Thomas Hohn rebased onto patch set 7
CR +1V +103/06/23, 05:41 -
core-ci voted on patch set 7 V +1 03/06/23, 05:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38511
-
Benni Mack voted on patch set 7 V +1 CR +1 03/06/23, 08:29
-
Benni Mack commented on patch set 7 03/06/23, 08:29
Reply
Done -
Stefan Bürk voted on patch set 7 V +2 CR +2 03/06/23, 08:34
-
Stefan Bürk merged patch set 8 03/06/23, 08:34