From 79a5fa48720aa347a975d5c0208a182d29902a0a Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Mon, 3 Jul 2023 18:24:56 +0200
Subject: [PATCH] [BUGFIX] Prevent undefined array key warnings in
 PageRepository

Resolves: #101194
Releases: main, 12.4, 11.5
Change-Id: I431e0af6b35d85aed0a3834c16b9f75c2923bfaa
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79634
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
---
 .../core/Classes/Domain/Repository/PageRepository.php  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php b/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php
index 11ff729390a2..a66410a8ddc8 100644
--- a/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php
+++ b/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php
@@ -1024,20 +1024,20 @@ class PageRepository implements LoggerAwareInterface
             return [];
         }
 
-        $dokType = (int)$page['doktype'];
-        $shortcutMode = (int)$page['shortcut_mode'];
+        $dokType = (int)($page['doktype'] ?? 0);
+        $shortcutMode = (int)($page['shortcut_mode'] ?? 0);
 
-        if ($dokType === self::DOKTYPE_SHORTCUT && ($page['shortcut'] || $shortcutMode)) {
+        if ($dokType === self::DOKTYPE_SHORTCUT && (($shortcut = (int)($page['shortcut'] ?? 0)) || $shortcutMode)) {
             if ($shortcutMode === self::SHORTCUT_MODE_NONE) {
                 // No shortcut_mode set, so target is directly set in $page['shortcut']
                 $searchField = 'uid';
-                $searchUid = (int)$page['shortcut'];
+                $searchUid = $shortcut;
             } elseif ($shortcutMode === self::SHORTCUT_MODE_FIRST_SUBPAGE || $shortcutMode === self::SHORTCUT_MODE_RANDOM_SUBPAGE) {
                 // Check subpages - first subpage or random subpage
                 $searchField = 'pid';
                 // If a shortcut mode is set and no valid page is given to select subpages
                 // from use the actual page.
-                $searchUid = (int)$page['shortcut'] ?: $page['uid'];
+                $searchUid = $shortcut ?: $page['uid'];
             } elseif ($shortcutMode === self::SHORTCUT_MODE_PARENT_PAGE) {
                 // Shortcut to parent page
                 $searchField = 'uid';
-- 
GitLab