[BUGFIX] Fix some PHP Notices thrown when rendering page module 58/54558/9
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Mon, 6 Nov 2017 08:12:26 +0000 (09:12 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 16 Nov 2017 07:28:45 +0000 (08:28 +0100)
Resolves: #82921
Releases: master, 8.7
Change-Id: Id26239e65321aa3653de849932a0be7e626bd653
Reviewed-on: https://review.typo3.org/54558
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
13 files changed:
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Classes/Module/ModuleLoader.php
typo3/sysext/backend/Classes/Template/ModuleTemplate.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
typo3/sysext/core/Classes/Log/LogManager.php
typo3/sysext/core/Classes/Session/Backend/DatabaseSessionBackend.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/extbase/Classes/Utility/ExtensionUtility.php
typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php
typo3/sysext/t3editor/Configuration/TCA/Overrides/tt_content.php

index 7c7b656..07afbae 100644 (file)
@@ -991,14 +991,14 @@ class PageLayoutController
         $this->buttonBar->addButton($shortcutButton);
 
         // Cache
-        if (!$this->modTSconfig['properties']['disableAdvanced']) {
+        if (empty($this->modTSconfig['properties']['disableAdvanced'])) {
             $clearCacheButton = $this->buttonBar->makeLinkButton()
                 ->setHref(BackendUtility::getModuleUrl($this->moduleName, ['id' => $this->pageinfo['uid'], 'clear_cache' => '1']))
                 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
                 ->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
         }
-        if (!$this->modTSconfig['properties']['disableIconToolbar']) {
+        if (empty($this->modTSconfig['properties']['disableIconToolbar'])) {
             // Edit page properties and page language overlay icons
             if ($this->pageIsNotLockedForEditors() && $this->getBackendUser()->checkLanguageAccess(0)) {
                 // Edit localized pages only when one specific language is selected
index e742979..aec0156 100644 (file)
@@ -139,7 +139,7 @@ class ModuleLoader
     public function checkMod($name)
     {
         // Check for own way of configuring module
-        if (is_array($GLOBALS['TBE_MODULES']['_configuration'][$name]['configureModuleFunction'])) {
+        if (is_array($GLOBALS['TBE_MODULES']['_configuration'][$name]['configureModuleFunction'] ?? false)) {
             trigger_error('Registering a module using "configureModuleFunction" is deprecated and will be removed in TYPO3 v10.', E_USER_DEPRECATED);
             $obj = $GLOBALS['TBE_MODULES']['_configuration'][$name]['configureModuleFunction'];
             if (is_callable($obj)) {
@@ -159,14 +159,13 @@ class ModuleLoader
         if (empty($setupInformation['configuration'])) {
             return 'notFound';
         }
-        if (
-            $setupInformation['configuration']['shy']
+        $finalModuleConfiguration = $setupInformation['configuration'];
+        if (!empty($finalModuleConfiguration['shy'])
             || !$this->checkModAccess($name, $setupInformation['configuration'])
             || !$this->checkModWorkspace($name, $setupInformation['configuration'])
         ) {
             return false;
         }
-        $finalModuleConfiguration = $setupInformation['configuration'];
         $finalModuleConfiguration['name'] = $name;
         // Language processing. This will add module labels and image reference to the internal ->moduleLabels array of the LANG object.
         $this->addLabelsForModule($name, ($finalModuleConfiguration['labels'] ?? $setupInformation['labels']));
@@ -193,9 +192,12 @@ class ModuleLoader
         }
 
         // check if there is a navigation component (like the pagetree)
-        if (is_array($this->navigationComponents[$name])) {
+        if (is_array($this->navigationComponents[$name] ?? false)) {
             $finalModuleConfiguration['navigationComponentId'] = $this->navigationComponents[$name]['componentId'];
-        } elseif ($mainModule && is_array($this->navigationComponents[$mainModule]) && $setupInformation['configuration']['inheritNavigationComponentFromMainModule'] !== false) {
+        } elseif ($mainModule
+            && is_array($this->navigationComponents[$mainModule] ?? false)
+            && $setupInformation['configuration']['inheritNavigationComponentFromMainModule'] !== false) {
+
             // navigation component can be overridden by the main module component
             $finalModuleConfiguration['navigationComponentId'] = $this->navigationComponents[$mainModule]['componentId'];
         }
index ffda419..6d1e5ed 100644 (file)
@@ -270,10 +270,10 @@ class ModuleTemplate
      */
     protected function loadStylesheets()
     {
-        if ($GLOBALS['TBE_STYLES']['stylesheet']) {
+        if (!empty($GLOBALS['TBE_STYLES']['stylesheet'])) {
             $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheet']);
         }
-        if ($GLOBALS['TBE_STYLES']['stylesheet2']) {
+        if (!empty($GLOBALS['TBE_STYLES']['stylesheet2'])) {
             $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheet2']);
         }
     }
index 161fe78..6b1f3b4 100644 (file)
@@ -362,7 +362,7 @@ class BackendUtility
         $output = [];
         $pid = $uid;
         $ident = $pid . '-' . $clause . '-' . $workspaceOL . ($additionalFields ? '-' . implode(',', $additionalFields) : '');
-        if (is_array($BEgetRootLine_cache[$ident])) {
+        if (is_array($BEgetRootLine_cache[$ident] ?? false)) {
             $output = $BEgetRootLine_cache[$ident];
         } else {
             $loopCheck = 100;
@@ -378,7 +378,20 @@ class BackendUtility
                 }
             }
             if ($uid == 0) {
-                $theRowArray[] = ['uid' => 0, 'title' => ''];
+                $theRowArray[] = [
+                    'uid' => 0,
+                    'pid' => null,
+                    'title' => '',
+                    'doktype' => null,
+                    'tsconfig_includes' => null,
+                    'TSconfig' => null,
+                    'is_siteroot' => null,
+                    't3ver_oid' => null,
+                    't3ver_wsid' => null,
+                    't3ver_state' => null,
+                    't3ver_stage' => null,
+                    'backend_layout_next_level' => null
+                ];
             }
             $c = count($theRowArray);
             foreach ($theRowArray as $val) {
@@ -422,7 +435,7 @@ class BackendUtility
     {
         static $getPageForRootline_cache = [];
         $ident = $uid . '-' . $clause . '-' . $workspaceOL;
-        if (is_array($getPageForRootline_cache[$ident])) {
+        if (is_array($getPageForRootline_cache[$ident]) ?? false) {
             $row = $getPageForRootline_cache[$ident];
         } else {
             $queryBuilder = static::getQueryBuilderForTable('pages');
@@ -846,7 +859,7 @@ class BackendUtility
         }
         $cacheHash = $res['hash'];
         // Get User TSconfig overlay
-        $userTSconfig = static::getBackendUserAuthentication()->userTS['page.'];
+        $userTSconfig = static::getBackendUserAuthentication()->userTS['page.'] ?? null;
         if (is_array($userTSconfig)) {
             ArrayUtility::mergeRecursiveWithOverrule($tsConfig, $userTSconfig);
             $cacheHash .= '_user' . static::getBackendUserAuthentication()->user['uid'];
@@ -1587,10 +1600,7 @@ class BackendUtility
     public static function getLabelFromItemlist($table, $col, $key)
     {
         // Check, if there is an "items" array:
-        if (is_array($GLOBALS['TCA'][$table])
-            && is_array($GLOBALS['TCA'][$table]['columns'][$col])
-            && is_array($GLOBALS['TCA'][$table]['columns'][$col]['config']['items'])
-        ) {
+        if (is_array($GLOBALS['TCA'][$table]['columns'][$col]['config']['items'] ?? false)) {
             // Traverse the items-array...
             foreach ($GLOBALS['TCA'][$table]['columns'][$col]['config']['items'] as $v) {
                 // ... and return the first found label where the value was equal to $key
@@ -1722,7 +1732,7 @@ class BackendUtility
         $recordTitle = '';
         if (is_array($GLOBALS['TCA'][$table])) {
             // If configured, call userFunc
-            if ($GLOBALS['TCA'][$table]['ctrl']['label_userFunc']) {
+            if (!empty($GLOBALS['TCA'][$table]['ctrl']['label_userFunc'])) {
                 $params['table'] = $table;
                 $params['row'] = $row;
                 $params['title'] = '';
@@ -1744,8 +1754,8 @@ class BackendUtility
                     $row['uid'],
                     $forceResult
                 );
-                if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']
-                    && ($GLOBALS['TCA'][$table]['ctrl']['label_alt_force'] || (string)$recordTitle === '')
+                if (!empty($GLOBALS['TCA'][$table]['ctrl']['label_alt'])
+                    && (!empty($GLOBALS['TCA'][$table]['ctrl']['label_alt_force']) || (string)$recordTitle === '')
                 ) {
                     $altFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true);
                     $tA = [];
@@ -1879,7 +1889,7 @@ class BackendUtility
                 break;
             case 'inline':
             case 'select':
-                if ($theColConf['MM']) {
+                if (!empty($theColConf['MM'])) {
                     if ($uid) {
                         // Display the title of MM related records in lists
                         if ($noRecordLookup) {
@@ -1955,7 +1965,7 @@ class BackendUtility
                         }
                     }
                     $l = self::getLabelsFromItemsList($table, $col, $value, $columnTsConfig);
-                    if ($theColConf['foreign_table'] && !$l && $GLOBALS['TCA'][$theColConf['foreign_table']]) {
+                    if (!empty($theColConf['foreign_table']) && !$l && !empty($GLOBALS['TCA'][$theColConf['foreign_table']])) {
                         if ($noRecordLookup) {
                             $l = $value;
                         } else {
@@ -2206,7 +2216,7 @@ class BackendUtility
                 }
         }
         // If this field is a password field, then hide the password by changing it to a random number of asterisk (*)
-        if (stristr($theColConf['eval'], 'password')) {
+        if (!empty($theColConf['eval']) && stristr($theColConf['eval'], 'password')) {
             $l = '';
             $randomNumber = rand(5, 12);
             for ($i = 0; $i < $randomNumber; $i++) {
index 37ce489..062807d 100644 (file)
@@ -377,7 +377,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
         $this->newSessionID = false;
         // $id is set to ses_id if cookie is present. Else set to FALSE, which will start a new session
         $id = $this->getCookie($this->name);
-        $this->svConfig = $GLOBALS['TYPO3_CONF_VARS']['SVCONF']['auth'];
+        $this->svConfig = $GLOBALS['TYPO3_CONF_VARS']['SVCONF']['auth'] ?? [];
 
         // If fallback to get mode....
         if (!$id && $this->getFallBack && $this->get_name) {
index 4679e42..60f1215 100644 (file)
@@ -179,7 +179,7 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
         // for these keys, for example "writerConfiguration"
         $configurationKey = $configurationType . 'Configuration';
         $configuration = $GLOBALS['TYPO3_CONF_VARS']['LOG'];
-        $result = $configuration[$configurationKey] ?: [];
+        $result = $configuration[$configurationKey] ?? [];
         // Walk from general to special (t3lib, t3lib.db, t3lib.db.foo)
         // and search for the most specific configuration
         foreach ($explodedName as $partOfClassName) {
index ca73309..2917ef9 100644 (file)
@@ -51,7 +51,7 @@ class DatabaseSessionBackend implements SessionBackendInterface
      */
     public function initialize(string $identifier, array $configuration)
     {
-        $this->hasAnonymousSessions = (bool)$configuration['has_anonymous'];
+        $this->hasAnonymousSessions = (bool)($configuration['has_anonymous'] ?? false);
         $this->configuration = $configuration;
     }
 
index 2989a73..3f330b6 100644 (file)
@@ -947,20 +947,27 @@ class TemplateService
 
         // @todo Change to use new API
         foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $files) {
-            if ((is_array($files) || $files instanceof \ArrayAccess) && ($files['ext_typoscript_constants.txt'] || $files['ext_typoscript_constants.typoscript'] || $files['ext_typoscript_setup.txt'] || $files['ext_typoscript_setup.typoscript'])) {
+            if ((is_array($files) || $files instanceof \ArrayAccess)
+                && (
+                    !empty($files['ext_typoscript_constants.txt'])
+                    || !empty($files['ext_typoscript_constants.typoscript'])
+                    || !empty($files['ext_typoscript_setup.txt'])
+                    || !empty($files['ext_typoscript_setup.typoscript'])
+                )
+            ) {
                 $mExtKey = str_replace('_', '', $extKey);
                 $constants = '';
                 $config = '';
 
-                if ($files['ext_typoscript_constants.typoscript']) {
+                if (!empty($files['ext_typoscript_constants.typoscript'])) {
                     $constants = @file_get_contents($files['ext_typoscript_constants.typoscript']);
-                } elseif ($files['ext_typoscript_constants.txt']) {
+                } elseif (!empty($files['ext_typoscript_constants.txt'])) {
                     $constants = @file_get_contents($files['ext_typoscript_constants.txt']);
                 }
 
-                if ($files['ext_typoscript_setup.typoscript']) {
+                if (!empty($files['ext_typoscript_setup.typoscript'])) {
                     $config = @file_get_contents($files['ext_typoscript_setup.typoscript']);
-                } elseif ($files['ext_typoscript_setup.txt']) {
+                } elseif (!empty($files['ext_typoscript_setup.txt'])) {
                     $config = @file_get_contents($files['ext_typoscript_setup.txt']);
                 }
 
index 49ea69e..f41e83f 100644 (file)
@@ -294,7 +294,7 @@ class ExtensionManagementUtility
 
             $fieldExists = false;
             $newPosition = '';
-            if (is_array($GLOBALS['TCA'][$table]['palettes'])) {
+            if (is_array($GLOBALS['TCA'][$table]['palettes'] ?? false)) {
                 // Get the palette names used in current showitem
                 $paletteCount = preg_match_all('/(?:^|,)                    # Line start or a comma
                                        (?:
@@ -305,6 +305,9 @@ class ExtensionManagementUtility
                     $paletteNames = array_filter(array_merge($paletteMatches[1], $paletteMatches[2]));
                     if (!empty($paletteNames)) {
                         foreach ($paletteNames as $paletteName) {
+                            if (!isset($GLOBALS['TCA'][$table]['palettes'][$paletteName])) {
+                                continue;
+                            }
                             $palette = $GLOBALS['TCA'][$table]['palettes'][$paletteName];
                             switch ($positionIdentifier) {
                                 case 'after':
@@ -901,9 +904,9 @@ class ExtensionManagementUtility
         $options = [
             'module' => true,
             'moduleName' => $fullModuleSignature,
-            'access' => $moduleConfiguration['access'] ?: 'user,group'
+            'access' => !empty($moduleConfiguration['access']) ? $moduleConfiguration['access'] : 'user,group'
         ];
-        if ($moduleConfiguration['routeTarget']) {
+        if (!empty($moduleConfiguration['routeTarget'])) {
             $options['target'] = $moduleConfiguration['routeTarget'];
         }
 
@@ -979,10 +982,10 @@ class ExtensionManagementUtility
         if (empty($key)) {
             throw new \RuntimeException('No extension key set in addLLrefForTCAdescr(). Provide it as third parameter', 1507321596);
         }
-        if (!is_array($GLOBALS['TCA_DESCR'][$key])) {
+        if (!is_array($GLOBALS['TCA_DESCR'][$key] ?? false)) {
             $GLOBALS['TCA_DESCR'][$key] = [];
         }
-        if (!is_array($GLOBALS['TCA_DESCR'][$key]['refs'])) {
+        if (!is_array($GLOBALS['TCA_DESCR'][$key]['refs'] ?? false)) {
             $GLOBALS['TCA_DESCR'][$key]['refs'] = [];
         }
         $GLOBALS['TCA_DESCR'][$key]['refs'][] = $file;
index ac66692..71cd8d4 100644 (file)
@@ -1641,7 +1641,7 @@ class GeneralUtility
             // Closing tag.
             $tagName = $tagName[0] === 'n' && MathUtility::canBeInterpretedAsInteger($testNtag) ? (int)$testNtag : $tagName;
             // Test for alternative index value:
-            if ((string)$val['attributes']['index'] !== '') {
+            if ((string)($val['attributes']['index'] ?? '') !== '') {
                 $tagName = $val['attributes']['index'];
             }
             // Setting tag-values, manage stack:
index 5ecadfd..85ab703 100644 (file)
@@ -59,7 +59,7 @@ class ExtensionUtility
         $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName)));
 
         $pluginSignature = strtolower($extensionName . '_' . $pluginName);
-        if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName])) {
+        if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName] ?? false)) {
             $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName] = [];
         }
         foreach ($controllerActions as $controllerName => $actionsList) {
index 404dd91..badf8a6 100644 (file)
@@ -220,7 +220,7 @@ class LocalizationUtility
     {
         $configurationManager = static::getConfigurationManager();
         $frameworkConfiguration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName);
-        if (!is_array($frameworkConfiguration['_LOCAL_LANG'])) {
+        if (!is_array($frameworkConfiguration['_LOCAL_LANG'] ?? false)) {
             return;
         }
         self::$LOCAL_LANG_UNSET[$languageFilePath] = [];
index 1238287..263f0da 100644 (file)
@@ -3,13 +3,13 @@ defined('TYPO3_MODE') or die();
 
 // Activate t3editor for tt_content type HTML if this type exists
 if (is_array($GLOBALS['TCA']['tt_content']['types']['html'])) {
-    if (!is_array($GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides'])) {
+    if (!isset($GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides'])) {
         $GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides'] = [];
     }
-    if (!is_array($GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext'])) {
+    if (!isset($GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext'])) {
         $GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext'] = [];
     }
-    if (!is_array($GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext']['config'])) {
+    if (!isset($GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext']['config'])) {
         $GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext']['config'] = [];
     }
     $GLOBALS['TCA']['tt_content']['types']['html']['columnsOverrides']['bodytext']['config']['renderType'] = 't3editor';