[BUGFIX] PHP warnings in ElementBrowser 25/26825/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Wed, 15 Jan 2014 00:43:18 +0000 (01:43 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Wed, 15 Jan 2014 12:58:51 +0000 (13:58 +0100)
The ElementBrowser tries to access array indexes
which do not exists.
Fix this to prevent PHP warnings.

Resolves: #54995
Releases: 6.2, 6.1
Change-Id: Ief660ae535f01bc593617667ce7eb81f8cd78cd3
Reviewed-on: https://review.typo3.org/26825
Reviewed-by: Stefan Neufeind
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 1ddcdcb..811c857 100644 (file)
@@ -400,9 +400,9 @@ class ElementBrowser {
                        $P2['formName'] = $this->P['formName'];
                        $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
                        $P2['fieldChangeFuncHash'] = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(serialize($this->P['fieldChangeFunc']));
-                       $P2['params']['allowedExtensions'] = $this->P['params']['allowedExtensions'];
-                       $P2['params']['blindLinkOptions'] = $this->P['params']['blindLinkOptions'];
-                       $P2['params']['blindLinkFields'] = $this->P['params']['blindLinkFields'];
+                       $P2['params']['allowedExtensions'] = isset($this->P['params']['allowedExtensions']) ? $this->P['params']['allowedExtensions'] : '';
+                       $P2['params']['blindLinkOptions'] = isset($this->P['params']['blindLinkOptions']) ? $this->P['params']['blindLinkOptions'] : '';
+                       $P2['params']['blindLinkFields'] = isset($this->P['params']['blindLinkFields']) ? $this->P['params']['blindLinkFields']: '';
                        $addPassOnParams .= \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('P', $P2);
                        $JScode .= '
                                function link_typo3Page(id,anchor) {    //
@@ -695,15 +695,30 @@ class ElementBrowser {
        public function main_rte($wiz = 0) {
                // Starting content:
                $content = $this->doc->startPage('RTE link');
+
                // Initializing the action value, possibly removing blinded values etc:
-               $allowedItems = array_diff(explode(',', 'page,file,folder,url,mail,spec'), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkOptions'], 1));
-               $allowedItems = array_diff($allowedItems, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->P['params']['blindLinkOptions']));
+               $blindLinkOptions = isset($this->thisConfig['blindLinkOptions'])
+                       ? GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkOptions'], TRUE)
+                       : array();
+               $pBlindLinkOptions = isset($this->P['params']['blindLinkOptions'])
+                       ? GeneralUtility::trimExplode(',', $this->P['params']['blindLinkOptions'])
+                       : array();
+               $allowedItems = array_diff(array('page', 'file', 'folder', 'url', 'mail', 'spec'), $blindLinkOptions, $pBlindLinkOptions);
+
                // Call hook for extra options
                foreach ($this->hookObjects as $hookObject) {
                        $allowedItems = $hookObject->addAllowedItems($allowedItems);
                }
+
                // Removing link fields if configured
-               $allowedFields = array_diff(array('target', 'title', 'class', 'params'), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->P['params']['blindLinkFields'], TRUE));
+               $blindLinkFields = isset($this->thisConfig['blindLinkFields'])
+                       ? GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE)
+                       : array();
+               $pBlindLinkFields = isset($this->P['params']['blindLinkFields'])
+                       ? GeneralUtility::trimExplode(',', $this->P['params']['blindLinkFields'], TRUE)
+                       : array();
+               $allowedFields = array_diff(array('target', 'title', 'class', 'params'), $blindLinkFields, $pBlindLinkFields);
+
                // If $this->act is not allowed, default to first allowed
                if (!in_array($this->act, $allowedItems)) {
                        $this->act = reset($allowedItems);