[BUGFIX] Properly check existence of array item 43/29343/6
authorMarkus Klein <klein.t3@mfc-linz.at>
Thu, 10 Apr 2014 16:01:56 +0000 (18:01 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 6 May 2014 10:16:08 +0000 (12:16 +0200)
The flexform converter in ContentObjectRenderer tries to access
an array element on a non-array.

Check existence with isset() first.

Resolves: #57809
Releases: 6.2, 6.1
Change-Id: I8e6111afee3a639b3077dc59bc2e32b72fa12f5c
Reviewed-on: https://review.typo3.org/29343
Reviewed-by: Oliver Klee
Tested-by: Jost Baron
Reviewed-by: Wouter Wolters
Reviewed-by: Julian Wundrak
Tested-by: Julian Wundrak
Reviewed-by: Stefan Neufeind
Reviewed-by: Stefan Froemken
Tested-by: Stefan Froemken
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 1ef57d7..8b32c41 100644 (file)
@@ -1161,21 +1161,26 @@ class ContentObjectRenderer {
        /**
         * Converts a given config in Flexform to a conf-array
         *
-        * @param string $flexData Flexform data
+        * @param string|array $flexData Flexform data
         * @param array $conf Array to write the data into, by reference
         * @param boolean $recursive Is set if called recursive. Don't call function with this parameter, it's used inside the function only
         * @return void
-        * @access public
         */
        public function readFlexformIntoConf($flexData, &$conf, $recursive = FALSE) {
-               if ($recursive === FALSE) {
+               if ($recursive === FALSE && is_string($flexData)) {
                        $flexData = GeneralUtility::xml2array($flexData, 'T3');
                }
-               if (is_array($flexData)) {
-                       if (isset($flexData['data']['sDEF']['lDEF'])) {
-                               $flexData = $flexData['data']['sDEF']['lDEF'];
+               if (isset($flexData['data']['sDEF']['lDEF'])) {
+                       $flexData = $flexData['data']['sDEF']['lDEF'];
+               }
+               if (!is_array($flexData)) {
+                       return;
+               }
+               foreach ($flexData as $key => $value) {
+                       if (!is_array($value)) {
+                               continue;
                        }
-                       foreach ($flexData as $key => $value) {
+                       if (isset($value['el'])) {
                                if (is_array($value['el']) && count($value['el']) > 0) {
                                        foreach ($value['el'] as $ekey => $element) {
                                                if (isset($element['vDEF'])) {
@@ -1191,9 +1196,9 @@ class ContentObjectRenderer {
                                } else {
                                        $this->readFlexformIntoConf($value['el'], $conf[$key], TRUE);
                                }
-                               if ($value['vDEF']) {
-                                       $conf[$key] = $value['vDEF'];
-                               }
+                       }
+                       if (isset($value['vDEF'])) {
+                               $conf[$key] = $value['vDEF'];
                        }
                }
        }