in2code-de / powermail

This is the official repository of the TYPO3 extension powermail! Powermail is a well-known, editor-friendly, powerful and easy mailform extension for TYPO3
https://in2code.de
88 stars 174 forks source link

Redirect is not triggered when $mail parameter is missing on success page #876

Closed mawo closed 4 months ago

mawo commented 1 year ago

TYPO3 v11.5 Powermail v10.7.2

When accessing the "success" URL without mail data I expect a redirect (or forward) to the mail form.

Instead an error message is shown:

1298012500 TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException
Required argument "mail" is not set for In2code\Powermail\Controller\FormController->create

The URL configuration looks like this (for the case it is a configuration issue at our side):

routeEnhancers:
  Powermail:
    type: Extbase
    extension: Powermail
    plugin: Pi1
    routes:
      -
        routePath: /
        _controller: 'Form::form'
      -
        routePath: /gesendet
        _controller: 'Form::create'
      -
        routePath: /bestaetigung
        _controller: 'Form::confirmation'

When accessing the URL /path/to/form/gesendet the error mentioned above is shown.

The source code in FormController looks like the redirect should be triggered. But it is not. see initializeCreateAction():

    public function initializeCreateAction(): void
    {
        …
        $this->forwardIfMailParamEmpty();
        …
    }

The function forwardIfMailParamEmpty() returns a ForwardResponse but the response is never used.

    protected function forwardIfMailParamEmpty(): ?ForwardResponse
    {
        $arguments = $this->request->getArguments();
        if (empty($arguments['mail'])) {
            $logger = ObjectUtility::getLogger(__CLASS__);
            $logger->warning('Redirect (mail empty)', $arguments);
            return new ForwardResponse('form');
        }
        return null;
    }
Zillion01 commented 1 year ago

I confirm this bug. It happens with spam. I do not use a routeEnhancer.

TYPO3 v11.5.27 Powermail v10.7.2 PHP 8.1

I ithink the code needs to be changed in

if (!isset($arguments['mail'])) {

dmnkhhn commented 7 months ago

The redirect works if you replace return new ForwardResponse('form'); with $this->forward('form');

edit: which is far from perfect as the forward method is marked as deprecated.

mawo commented 4 months ago

I confirm, this is solved at least in Powermail 10.8.1