in2code-de / powermail_cond

Add conditions (via AJAX) to TYPO3 powermail forms for fields and pages
8 stars 23 forks source link

unable to load powermail form #30

Open marcovonarx opened 5 years ago

marcovonarx commented 5 years ago

we use version 3.5.2, but it looks this may happen on 6.1 as well. in some rare cases powermail_cond is not able to fetch a form object and generates an exception

Uncaught TYPO3 Exception: Argument 1 passed to In2code\PowermailCond\Controller\ConditionController::setTextFields() must be an instance of In2code\Powermail\Domain\Model\Form, null given, called in /typo3conf/ext/powermail_cond/Classes/Controller/ConditionController.php on line 60 | TypeError thrown in file /typo3conf/ext/powermail_cond/Classes/Controller/ConditionController.php in line 77. Requested URL: ...../online-antrag/?type=3132

one work around could be (in version 3.5.2) In2code\PowermailCond\Controller\ConditionController starting at line 59

        $form = $formRepository->findByIdentifier($this->powermailArguments['mail']['form']);
        $this->setTextFields($form);

to

        $form = $formRepository->findByIdentifier($this->powermailArguments['mail']['form']);
        if (is_null($form)) return null;
        $this->setTextFields($form);
Mainbird commented 3 years ago

Hi :)

I have noticed the same issue with version 8.1.0, but the buildConditionAction is currently returning a string

https://github.com/einpraegsam/powermail_cond/blob/develop/Classes/Controller/ConditionController.php#L55

So I think something like this:

/** @var Form $form */
$form = $formRepository->findByIdentifier($this->powermailArguments['mail']['form']);

if ($form === null) {
    return json_encode([]):
}

should also be fine, but I don't know if we should send some error data or something else to the frontend so that we can handle/ ignore the error.

What do you think? :)