[TASK] E_NOTICE reduction 84/54884/7
authorPawel Cieslik <p.cieslik@macopedia.pl>
Thu, 30 Nov 2017 10:50:00 +0000 (11:50 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 18 Mar 2018 12:17:30 +0000 (13:17 +0100)
Reduce number of E_NOTICE thrown by TYPO3

Resolves: #70584
Releases: master
Change-Id: I46fb54e51b24af5721efaa9507b32b86f38fc325
Reviewed-on: https://review.typo3.org/54884
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/about/Classes/Controller/AboutController.php
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/extbase/Classes/Core/Bootstrap.php
typo3/sysext/extbase/Classes/Utility/ExtensionUtility.php

index 88452a2..ace9b65 100644 (file)
@@ -109,16 +109,20 @@ class AboutController
      */
     protected function getSubModuleData(ModuleLoader $loadedModules, $moduleName): array
     {
+        if (empty($loadedModules->modules[$moduleName]['sub'])) {
+            return [];
+        }
+
         $subModulesData = [];
         foreach ($loadedModules->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
             $moduleLabels = $loadedModules->getLabelsForModule($moduleName . '_' . $subModuleName);
             $subModuleData = [];
             $subModuleData['name'] = $subModuleName;
-            $subModuleData['icon'] = $subModuleInfo['icon'];
-            $subModuleData['iconIdentifier'] = $subModuleInfo['iconIdentifier'];
-            $subModuleData['label'] = $moduleLabels['title'];
-            $subModuleData['shortDescription'] = $moduleLabels['shortdescription'];
-            $subModuleData['longDescription'] = $moduleLabels['description'];
+            $subModuleData['icon'] = $subModuleInfo['icon'] ?? null;
+            $subModuleData['iconIdentifier'] = $subModuleInfo['iconIdentifier'] ?? null;
+            $subModuleData['label'] = $moduleLabels['title'] ?? null;
+            $subModuleData['shortDescription'] = $moduleLabels['shortdescription'] ?? null;
+            $subModuleData['longDescription'] = $moduleLabels['description'] ?? null;
             $subModulesData[] = $subModuleData;
         }
         return $subModulesData;
index 5cc7768..2614d07 100644 (file)
@@ -378,7 +378,7 @@ class PageLayoutController
             }
         }
         // Setting alternative default label:
-        if (($this->modSharedTSconfig['properties']['defaultLanguageLabel'] || $this->modTSconfig['properties']['defaultLanguageLabel']) && isset($this->MOD_MENU['language'][0])) {
+        if ((!empty($this->modSharedTSconfig['properties']['defaultLanguageLabel']) || !empty($this->modTSconfig['properties']['defaultLanguageLabel'])) && isset($this->MOD_MENU['language'][0])) {
             $this->MOD_MENU['language'][0] = $this->modTSconfig['properties']['defaultLanguageLabel'] ? $this->modTSconfig['properties']['defaultLanguageLabel'] : $this->modSharedTSconfig['properties']['defaultLanguageLabel'];
         }
         // Initialize the avaiable actions
@@ -386,7 +386,9 @@ class PageLayoutController
         // Clean up settings
         $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
         // For all elements to be shown in draft workspaces & to also show hidden elements by default if user hasn't disabled the option
-        if ($this->getBackendUser()->workspace != 0 || $this->MOD_SETTINGS['tt_content_showHidden'] !== '0') {
+        if ($this->getBackendUser()->workspace != 0 ||
+            isset($this->MOD_SETTINGS['tt_content_showHidden']) && $this->MOD_SETTINGS['tt_content_showHidden'] !== '0'
+        ) {
             $this->MOD_SETTINGS['tt_content_showHidden'] = 1;
         }
         // Make action menu from available actions
index 2889c75..633a7de 100644 (file)
@@ -568,7 +568,7 @@ abstract class AbstractConditionMatcher
         $vars = explode('|', $var);
         $c = count($vars);
         $k = trim($vars[0]);
-        $theVar = isset($source) ? $source[$k] : $GLOBALS[$k];
+        $theVar = isset($source) ? ($source[$k] ?? null) : ($GLOBALS[$k] ?? null);
         for ($a = 1; $a < $c; $a++) {
             if (!isset($theVar)) {
                 break;
index d7022fe..5ec8b99 100644 (file)
@@ -152,7 +152,7 @@ class FileWriter extends AbstractWriter
      */
     protected function openLogFile()
     {
-        if (isset(self::$logFileHandles[$this->logFile]) && is_resource(self::$logFileHandles[$this->logFile])) {
+        if (isset(self::$logFileHandles[$this->logFile]) && is_resource(self::$logFileHandles[$this->logFile] ?? false)) {
             return;
         }
 
index f8c9c50..f3aecc5 100644 (file)
@@ -322,7 +322,7 @@ class TypoScriptParser
                 // If multiline is enabled. Escape by ')'
                 if ($this->multiLineEnabled) {
                     // Multiline ends...
-                    if ($line[0] === ')') {
+                    if (!empty($line[0]) && $line[0] === ')') {
                         if ($this->syntaxHighLight) {
                             $this->regHighLight('operator', $lineP, strlen($line) - 1);
                         }
index aab79e5..0d9308d 100644 (file)
@@ -1062,7 +1062,7 @@ class ExtensionManagementUtility
         // Change the priority (and other values) from $GLOBALS['TYPO3_CONF_VARS']
         // $GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey]['priority']
         // even the activation is possible (a unix service might be possible on windows for some reasons)
-        if (is_array($GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey])) {
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey] ?? false)) {
             // No check is done here - there might be configuration values only the service type knows about, so
             // we pass everything
             $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey] = array_merge($GLOBALS['T3_SERVICES'][$serviceType][$serviceKey], $GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey]);
@@ -1463,9 +1463,15 @@ tt_content.' . $key . $suffix . ' {
                 }
                 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.']['defaultContentRendering'] .= $content;
             } else {
+                if (!isset($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$afterStaticUid])) {
+                    $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$afterStaticUid] = '';
+                }
                 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$afterStaticUid] .= $content;
             }
         } else {
+            if (!isset($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type])) {
+                $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type] = '';
+            }
             $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type] .= $content;
         }
     }
index 98b68c4..e8b50a2 100644 (file)
@@ -111,7 +111,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
     public function configureObjectManager()
     {
         $frameworkSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
-        if (!is_array($frameworkSetup['objects'])) {
+        if (!isset($frameworkSetup['objects']) || !is_array($frameworkSetup['objects'])) {
             return;
         }
         $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
index bd448eb..3b5af5e 100644 (file)
@@ -211,7 +211,9 @@ tt_content.' . $pluginSignature . ' {
      */
     public static function registerTypeConverter($typeConverterClassName)
     {
-        if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'])) {
+        if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters']) ||
+            !is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'])
+        ) {
             $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = [];
         }
         if (!in_array($typeConverterClassName, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'])) {