Project

General

Profile

Actions

Bug #88628

closed

Redirect call on controller level is firing the action again

Added by Ronny Hauptvogel over 5 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
-- undefined --
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2019-06-25
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Redirect
Complexity:
Is Regression:
Sprint Focus:

Description

I'm not really sure if this is a bug or something has changed here, but the behaviour in TYPO3 8 is not the same like in TYPO3 9.

It seems that a redirect call ($this->redirect()) on controller level will call the action again which have fired the redirect.
So if I do something like that:

class FormController extends ActionController
{
    public function showAction(): void
    {
        // nothing to do just show the form
    }

    public function redirectAction(): void
    {
        $mailData = [
            'sender' => $this->settings['senderEmail'],
            'senderName' => $this->settings['senderName'],
            'subject' => $this->settings['subject'],
            'receivers' => explode(',', $this->settings['receiverEmails']),
            'html' => '<h1>Redirect Test</h1>',
        ];

        if (MailerUtility::send($mailData)) {
            $this->redirect(
                null,
                null,
                null,
                null,
                $this->settings['redirectPageId']
            );
        }
    }
}

then the mail will be sent only once in TYPO3 8, but twice in TYPO3 9. Without the redirect call, the mail will be sent once in TYPO3 9, too. Maybe someone can tell me more about this behaviour?

Furthermore I have created a little example extension to reproduce this, which you can find in the attachment. The dependencies are set to TYPO3 9, but this example extension works in TYPO3 8, too.

  1. just install and enable the extension
  2. include the extension plugin and set some flexform data
  3. take a look at the frontend rendering of this plugin and submit the example form

Files

redirect-test.zip (10 KB) redirect-test.zip Ronny Hauptvogel, 2019-06-25 16:14
mail-example.png (57.2 KB) mail-example.png Ronny Hauptvogel, 2020-01-16 11:44
example.png (15.6 KB) example.png Ronny Hauptvogel, 2020-01-16 11:44

Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #91156: Double Action execution if redirect at its endNew2020-04-21

Actions
Actions

Also available in: Atom PDF