Skip to content

Commit df25655

Browse files
o-basbuerk
authored andcommitted
[BUGFIX] Prevent undefined array key in PageRepository
Since `->getPage()` might return an empty array, we need to check this properly on parent page evaluation. Resolves: #108351 Related: #17406 Releases: main Change-Id: Ib78be6f1107b809e291d69fbb744b6be44d843db Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/91918 Tested-by: Lina Wolf <[email protected]> Tested-by: Stefan Bürk <[email protected]> Reviewed-by: Lina Wolf <[email protected]> Reviewed-by: Oliver Klee <[email protected]> Reviewed-by: Stefan Bürk <[email protected]> Tested-by: core-ci <[email protected]>
1 parent 848ff37 commit df25655

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

typo3/sysext/core/Classes/Domain/Repository/PageRepository.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,14 +1133,13 @@ protected function getPageShortcut($shortcutFieldValue, $shortcutMode, $thisUid,
11331133
// Find $page record depending on shortcut mode:
11341134
if ($shortcutMode === self::SHORTCUT_MODE_PARENT_PAGE) {
11351135
$parent = $this->getPage(($shortcutId ?: (int)$thisUid), $disableGroupCheck);
1136-
$referencedPageRecord = $this->getPage((int)$parent['pid'], $disableGroupCheck);
1137-
if (empty($referencedPageRecord)) {
1136+
if ($parent === [] || ($referencedPageRecord = $this->getPage((int)($parent['pid'] ?? 0), $disableGroupCheck)) === []) {
11381137
$message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to its parent page. However, the parent page is not accessible.';
11391138
throw new ShortcutTargetPageNotFoundException($message, 1301648358);
11401139
}
11411140
} elseif ($shortcutMode === self::DOKTYPE_SHORTCUT || ($shortcutMode !== self::SHORTCUT_MODE_FIRST_SUBPAGE && $shortcutId)) {
11421141
$referencedPageRecord = $this->getPage($shortcutId, $disableGroupCheck);
1143-
if (empty($referencedPageRecord)) {
1142+
if ($referencedPageRecord === []) {
11441143
$message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a page, which is not accessible (ID ' . $shortcutId . ').';
11451144
throw new ShortcutTargetPageNotFoundException($message, 1301648404);
11461145
}
@@ -1152,7 +1151,7 @@ protected function getPageShortcut($shortcutFieldValue, $shortcutMode, $thisUid,
11521151
];
11531152
$pageArray = $this->getMenu($shortcutId ?: (int)$thisUid, '*', 'sorting', 'AND pages.doktype NOT IN (' . implode(', ', $excludedDoktypes) . ')', true, $disableGroupCheck);
11541153
$referencedPageRecord = reset($pageArray);
1155-
if (empty($referencedPageRecord)) {
1154+
if ($referencedPageRecord === false || $referencedPageRecord === null) {
11561155
$message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a subpage. However, this page has no accessible subpages.';
11571156
throw new ShortcutTargetPageNotFoundException($message, 1301648328);
11581157
}

0 commit comments

Comments
 (0)