[TASK] Remove undefined offset notices in PageLinkBuilder 87/56587/2
authorTim Schreiner <schreiner.tim@gmail.com>
Fri, 6 Apr 2018 14:15:14 +0000 (16:15 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 14 Apr 2018 13:22:39 +0000 (15:22 +0200)
The PageLinkBuilder access some array keys that might not exist.
This leads to undefined offset notices.

Resolves: #84647
Releases: master
Change-Id: I50c44ba55364f0122bd88be851cd7c35aacd5220
Reviewed-on: https://review.typo3.org/56587
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joshua Westerheide <account@jdoubleu.de>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php

index 7c973a7..6f0ae4e 100644 (file)
@@ -329,13 +329,14 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
     public function getMountPointParameterFromRootPointMaps(int $pageId)
     {
         // Create map if not found already
+        $config = $this->getTypoScriptFrontendController()->config;
         $mountPointMap = $this->initializeMountPointMap(
-            $this->getTypoScriptFrontendController()->config['config']['MP_defaults'] ?: null,
-            $this->getTypoScriptFrontendController()->config['config']['MP_mapRootPoints'] ?: null
+            !empty($config['config']['MP_defaults']) ? $config['config']['MP_defaults'] : null,
+            !empty($config['config']['MP_mapRootPoints']) ? $config['config']['MP_mapRootPoints'] : null
         );
 
         // Finding MP var for Page ID:
-        if (is_array($mountPointMap[$pageId]) && !empty($mountPointMap[$pageId])) {
+        if (!empty($mountPointMap[$pageId])) {
             return implode(',', $mountPointMap[$pageId]);
         }
         return '';
@@ -502,8 +503,9 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
         }
         // typeNum
         $typeNum = $this->getTypoScriptFrontendController()->tmpl->setup[$target . '.']['typeNum'];
-        if (!MathUtility::canBeInterpretedAsInteger($typeOverride) && (int)$this->getTypoScriptFrontendController()->config['config']['forceTypeValue']) {
-            $typeOverride = (int)$this->getTypoScriptFrontendController()->config['config']['forceTypeValue'];
+        $config = $this->getTypoScriptFrontendController()->config;
+        if (!MathUtility::canBeInterpretedAsInteger($typeOverride) && !empty($config['config']['forceTypeValue']) && (int)$config['config']['forceTypeValue']) {
+            $typeOverride = (int)$config['config']['forceTypeValue'];
         }
         if ((string)$typeOverride !== '') {
             $typeNum = $typeOverride;