[BUGFIX] PHP warnings in ElementBrowser 24/26824/3
authorMarkus Klein <klein.t3@mfc-linz.at>
Tue, 14 Jan 2014 18:04:33 +0000 (19:04 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 15 Jan 2014 00:40:05 +0000 (01:40 +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/26824
Reviewed-by: Oliver Klee
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index c8d063a..78ebed4 100644 (file)
@@ -412,9 +412,9 @@ class ElementBrowser {
                        $P2['formName'] = $this->P['formName'];
                        $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
                        $P2['fieldChangeFuncHash'] = 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 .= GeneralUtility::implodeArrayForUrl('P', $P2);
                        $JScode .= '
                                function link_typo3Page(id,anchor) {    //
@@ -707,15 +707,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'), GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkOptions'], TRUE));
-               $allowedItems = array_diff($allowedItems, 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'), GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE), 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);