[BUGFIX] Error 500 on ajax request if no condition is set for form
authorAlex Kellner <alexander.kellner@in2code.de>
Thu, 3 Dec 2015 16:34:26 +0000 (17:34 +0100)
committerAlex Kellner <alexander.kellner@in2code.de>
Thu, 3 Dec 2015 16:34:26 +0000 (17:34 +0100)
Adding another if condition to controller action

Related: #72007

Classes/Controller/ConditionController.php
Classes/Domain/Model/ConditionContainer.php
Resources/Private/Templates/Condition/BuildCondition.html

index bad714e..750da1c 100644 (file)
@@ -81,21 +81,24 @@ class ConditionController extends ActionController {
 
                /** @var ConditionContainer $conditionContainer */
                $conditionContainer = $this->conditionContainerRepository->findOneByForm($form);
-               $arguments = $conditionContainer->applyConditions($form, $arguments);
+               if ($conditionContainer !== NULL) {
+                       $arguments = $conditionContainer->applyConditions($form, $arguments);
 
-               /** @var TypoScriptFrontendController $feUser */
-               $feUser = GeneralUtility::makeInstance(
-                       'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
-                       $GLOBALS['TYPO3_CONF_VARS'],
-                       0,
-                       0
-               );
-               $feUser->initFEuser();
-               $feUser->fe_user->setAndSaveSessionData('tx_powermail_cond', $arguments);
+                       /** @var TypoScriptFrontendController $feUser */
+                       $feUser = GeneralUtility::makeInstance(
+                               'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
+                               $GLOBALS['TYPO3_CONF_VARS'],
+                               0,
+                               0
+                       );
+                       $feUser->initFEuser();
+                       $feUser->fe_user->setAndSaveSessionData('tx_powermail_cond', $arguments);
 
-               unset($arguments['backup']);
-               unset($arguments['field']);
+                       unset($arguments['backup']);
+                       unset($arguments['field']);
 
-               return json_encode($arguments);
+                       return json_encode($arguments);
+               }
+               return NULL;
        }
 }
index e570453..1321cf4 100644 (file)
@@ -54,13 +54,6 @@ class ConditionContainer extends AbstractEntity {
         */
        protected $somethingChanged = TRUE;
 
-//     /**
-//      * @param QueryResult $conditions
-//      */
-//     public function __construct(QueryResult $conditions) {
-//             $this->conditions = $conditions;
-//     }
-
        /**
         * @param Form $form
         * @param array $arguments