[BUGFIX] EXT:form - Fix PHP warning in debug mode 85/48585/3
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Wed, 15 Jun 2016 10:48:52 +0000 (12:48 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 17 Jun 2016 07:39:15 +0000 (09:39 +0200)
Avoid PHP warning on empty filters configuration.

Resolves: #76642
Releases: master, 7.6
Change-Id: Ia1171867acd150a1fdd595bcea1bda58c98fac36
Reviewed-on: https://review.typo3.org/48585
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/form/Classes/Domain/Builder/FormBuilder.php

index 0336873..54f2f8a 100644 (file)
@@ -443,32 +443,35 @@ class FormBuilder
 
         if ($this->getIncomingData()->getIncomingField($elementName) !== null) {
             /* filter values and set it back to incoming fields */
-            $keys = ArrayUtility::filterAndSortByNumericKeys($userConfiguredElementTypoScript['filters.']);
-            foreach ($keys as $key) {
-                $class = $userConfiguredElementTypoScript['filters.'][$key];
-                if (
-                    (int)$key
-                    && strpos($key, '.') === false
-                ) {
-                    $filterArguments = $userConfiguredElementTypoScript['filters.'][$key . '.'];
-                    $filterClassName = $this->typoScriptRepository->getRegisteredClassName((string)$class, 'registeredFilters');
-                    if ($filterClassName !== null) {
-                        // toDo: handel array values
-                        if (is_string($this->getIncomingData()->getIncomingField($elementName))) {
-                            if (is_null($filterArguments)) {
-                                $filter = $this->objectManager->get($filterClassName);
-                            } else {
-                                $filter = $this->objectManager->get($filterClassName, $filterArguments);
-                            }
-                            if ($filter) {
-                                $value = $filter->filter($this->getIncomingData()->getIncomingField($elementName));
-                                $this->getIncomingData()->setIncomingField($elementName, $value);
-                            } else {
-                                throw new \RuntimeException('Class "' . $filterClassName . '" could not be loaded.');
+            $filters = isset($userConfiguredElementTypoScript['filters.']) ? $userConfiguredElementTypoScript['filters.'] : array();
+            if (!empty($filters)) {
+                $keys = ArrayUtility::filterAndSortByNumericKeys($filters);
+                foreach ($keys as $key) {
+                    $class = $userConfiguredElementTypoScript['filters.'][$key];
+                    if (
+                        (int)$key
+                        && strpos($key, '.') === false
+                    ) {
+                        $filterArguments = $userConfiguredElementTypoScript['filters.'][$key . '.'];
+                        $filterClassName = $this->typoScriptRepository->getRegisteredClassName((string)$class, 'registeredFilters');
+                        if ($filterClassName !== null) {
+                            // toDo: handel array values
+                            if (is_string($this->getIncomingData()->getIncomingField($elementName))) {
+                                if (is_null($filterArguments)) {
+                                    $filter = $this->objectManager->get($filterClassName);
+                                } else {
+                                    $filter = $this->objectManager->get($filterClassName, $filterArguments);
+                                }
+                                if ($filter) {
+                                    $value = $filter->filter($this->getIncomingData()->getIncomingField($elementName));
+                                    $this->getIncomingData()->setIncomingField($elementName, $value);
+                                } else {
+                                    throw new \RuntimeException('Class "' . $filterClassName . '" could not be loaded.');
+                                }
                             }
+                        } else {
+                            throw new \RuntimeException('Class "' . $filterClassName . '" not registered via TypoScript.');
                         }
-                    } else {
-                        throw new \RuntimeException('Class "' . $filterClassName . '" not registered via TypoScript.');
                     }
                 }
             }