Skip to content

Commit

Permalink
[BUGFIX] Prevent PHP warnings in PageRouter
Browse files Browse the repository at this point in the history
In some situations, "_page" might not be set
in the Route. This patch prevents undefined
array key warnings and also makes the code
more readable.

Resolves: #97369
Releases: main, 11.5
Change-Id: I47920cdeb641b52577590d710d692a91fca7c383
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74284
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
o-ba committed Apr 14, 2022
1 parent abf4ae2 commit e09e2df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions typo3/sysext/core/Classes/Routing/PageRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,13 @@ protected function buildPageArguments(Route $route, array $results, array $remai
return $enhancer->buildResult($route, $results, $remainingQueryParameters);
}
$page = $route->getOption('_page');
$pageId = (int)(isset($page['t3ver_oid']) && $page['t3ver_oid'] > 0 ? $page['t3ver_oid'] : $page['uid']);
$pageId = (int)($page['l10n_parent'] > 0 ? $page['l10n_parent'] : $pageId);
if ((int)($page['l10n_parent'] ?? 0) > 0) {
$pageId = (int)$page['l10n_parent'];
} elseif ((int)($page['t3ver_oid'] ?? 0) > 0) {
$pageId = (int)$page['t3ver_oid'];
} else {
$pageId = (int)($page['uid'] ?? 0);
}
$type = $this->resolveType($route, $remainingQueryParameters);
// See PageSlugCandidateProvider where this is added.
if ($page['MPvar'] ?? '') {
Expand Down

0 comments on commit e09e2df

Please sign in to comment.