Skip to content

Commit

Permalink
[BUGFIX] Guard array key access in TypoScriptFrontendController
Browse files Browse the repository at this point in the history
This change ensure guarded array key access to avoid corresponding
native PHP undefined array key access warnings in `getPageAndRootline`
of class `\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController`.

Resolves: #98352
Releases: main, 11.5
Change-Id: Ieefccd94ae3a2d0f6dc1ff198febf898d21f048f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75746
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
sbuerk authored and maddy2101 committed Sep 18, 2022
1 parent d7eed01 commit b136c7a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,8 @@ protected function getPageAndRootline(ServerRequestInterface $request)
}
}
// Spacer and sysfolders is not accessible in frontend
$isSpacerOrSysfolder = $this->page['doktype'] == PageRepository::DOKTYPE_SPACER || $this->page['doktype'] == PageRepository::DOKTYPE_SYSFOLDER;
$pageDoktype = (int)($this->page['doktype'] ?? 0);
$isSpacerOrSysfolder = $pageDoktype === PageRepository::DOKTYPE_SPACER || $pageDoktype === PageRepository::DOKTYPE_SYSFOLDER;
// Page itself is not accessible, but the parent page is a spacer/sysfolder
if ($isSpacerOrSysfolder && !empty($requestedPageRowWithoutGroupCheck)) {
try {
Expand Down Expand Up @@ -876,7 +877,7 @@ protected function getPageAndRootline(ServerRequestInterface $request)
}
}
// Is the ID a link to another page??
if ($this->page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
if ($pageDoktype === PageRepository::DOKTYPE_SHORTCUT) {
// We need to clear MP if the page is a shortcut. Reason is if the shortcut goes to another page, then we LEAVE the rootline which the MP expects.
$this->MP = '';
// saving the page so that we can check later - when we know
Expand All @@ -886,11 +887,12 @@ protected function getPageAndRootline(ServerRequestInterface $request)
$this->originalShortcutPage = $this->page;
$this->page = $this->sys_page->resolveShortcutPage($this->page, true);
$this->id = (int)$this->page['uid'];
$pageDoktype = (int)($this->page['doktype'] ?? 0);
}
// If the page is a mountpoint which should be overlaid with the contents of the mounted page,
// it must never be accessible directly, but only in the mountpoint context. Therefore we change
// the current ID and the user is redirected by checkPageForMountpointRedirect().
if ($this->page['doktype'] == PageRepository::DOKTYPE_MOUNTPOINT && $this->page['mount_pid_ol']) {
if ($pageDoktype === PageRepository::DOKTYPE_MOUNTPOINT && $this->page['mount_pid_ol']) {
$this->originalMountPointPage = $this->page;
$this->page = $this->sys_page->getPage($this->page['mount_pid']);
if (empty($this->page)) {
Expand All @@ -905,6 +907,7 @@ protected function getPageAndRootline(ServerRequestInterface $request)
$this->MP .= ',' . $this->page['uid'] . '-' . $this->originalMountPointPage['uid'];
}
$this->id = (int)$this->page['uid'];
$pageDoktype = (int)($this->page['doktype'] ?? 0);
}
// Gets the rootLine
try {
Expand Down

0 comments on commit b136c7a

Please sign in to comment.