[BUGFIX] Prevent warning on user settings reset 66/44666/4
authorNicole Cordes <typo3@cordes.co>
Tue, 10 Nov 2015 13:41:27 +0000 (14:41 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 13 Nov 2015 07:40:38 +0000 (08:40 +0100)
This patch adds an access check to array access and initializes
an empty state object if no configuration is found.

Resolves: #71315
Releases: master
Change-Id: I27aff6654939cee754d2aed008146a437a37762a
Reviewed-on: https://review.typo3.org/44666
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/UserSettingsController.php
typo3/sysext/backend/Classes/Tree/Pagetree/ExtdirectTreeCommands.php

index bab2be3..c1fe027 100644 (file)
@@ -204,7 +204,12 @@ class UserSettingsController
         $subkeys = GeneralUtility::trimExplode('.', $key);
         $array = &$this->getBackendUser()->uc;
         foreach ($subkeys as $subkey) {
-            $array = &$array[$subkey];
+            if (isset($array[$subkey])) {
+                $array =  &$array[$subkey];
+            } else {
+                $array = [];
+                break;
+            }
         }
         return $array;
     }
index 4473f37..2571397 100644 (file)
@@ -363,7 +363,11 @@ class ExtdirectTreeCommands
         /** @var $userSettingsController \TYPO3\CMS\Backend\Controller\UserSettingsController */
         $userSettingsController = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\UserSettingsController::class);
         $state = $userSettingsController->process('get', 'BackendComponents.States.' . $stateId);
-        $state->stateHash = (object) $state->stateHash;
+        if (empty($state)) {
+            $state = new \StdClass();
+            $state->stateHash = new \StdClass();
+        }
+        $state->stateHash = (object)$state->stateHash;
         $rootline = BackendUtility::BEgetRootLine($nodeId, '', $GLOBALS['BE_USER']->workspace != 0);
         $rootlineIds = array();
         foreach ($rootline as $pageData) {