[BUGFIX] ExtDirectApi uses an undefined variable 15/19115/2
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Wed, 6 Mar 2013 18:24:44 +0000 (22:24 +0400)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 20 Mar 2013 20:28:33 +0000 (21:28 +0100)
Method generateAPI() sets $className inside the condition but later uses
it without checking if it is empty or not. The result is a PHP warning
"Invalid argument supplied for foreach()".

Change-Id: I7fd2bf88374661a8b54023aee9fe2af5619471b0
Resolves: #46075
Releases: 6.0, 6.1
Reviewed-on: https://review.typo3.org/19115
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/ExtDirect/ExtDirectApi.php

index a9562c9..dedf0ab 100644 (file)
@@ -117,19 +117,19 @@ class ExtDirectApi {
                                }
                                if (is_array($configuration)) {
                                        $className = $configuration['callbackClass'];
-                               }
-                               $serverObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($className, FALSE);
-                               $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName] = array();
-                               foreach (get_class_methods($serverObject) as $methodName) {
-                                       $reflectionMethod = new \ReflectionMethod($serverObject, $methodName);
-                                       $numberOfParameters = $reflectionMethod->getNumberOfParameters();
-                                       $docHeader = $reflectionMethod->getDocComment();
-                                       $formHandler = strpos($docHeader, '@formHandler') !== FALSE;
-                                       $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName][] = array(
-                                               'name' => $methodName,
-                                               'len' => $numberOfParameters,
-                                               'formHandler' => $formHandler
-                                       );
+                                       $serverObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($className, FALSE);
+                                       $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName] = array();
+                                       foreach (get_class_methods($serverObject) as $methodName) {
+                                               $reflectionMethod = new \ReflectionMethod($serverObject, $methodName);
+                                               $numberOfParameters = $reflectionMethod->getNumberOfParameters();
+                                               $docHeader = $reflectionMethod->getDocComment();
+                                               $formHandler = strpos($docHeader, '@formHandler') !== FALSE;
+                                               $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName][] = array(
+                                                       'name' => $methodName,
+                                                       'len' => $numberOfParameters,
+                                                       'formHandler' => $formHandler
+                                               );
+                                       }
                                }
                        }
                }
@@ -220,4 +220,4 @@ class ExtDirectApi {
 }
 
 
-?>
\ No newline at end of file
+?>