Project

General

Profile

Actions

Bug #91156

open

Double Action execution if redirect at its end

Added by Kuba Wolski almost 4 years ago. Updated 8 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2020-04-21
Due date:
% Done:

0%

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

Description

Fresh installation Typo3 9.5.
After initial configuration, I created a very simple extenstion named 'test', with one controller named 'Test', and two actions 'test' and 'test2', and one frontend plugin named 'test'. I installed this extension and put a plugin onto my homepage.

Action 'test' is writing current date and time to a file, using file_put_contents with FILE_APPEND flag. At the end of 'test' a redirect to 'test2' is executed.

When action is served after a browser request, and after a redirect is complete, I can find 2 new lines in a file mentioned before.

I also prepared fresh Typo3 10.4 and the same problem occured.

<?php
namespace Test\Test\Controller;
class TestController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    public function testAction()
    {
        file_put_contents('abc.xyz', date('YmdHis') . "\n", FILE_APPEND);
        $this->redirect('test2');

    }

    public function test2Action()
    {
        echo 'test';
        exit;
    }
}
?>

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #88628: Redirect call on controller level is firing the action againRejected2019-06-25

Actions
Actions #1

Updated by Kuba Wolski almost 4 years ago

After long investigation, I found out, that the doubled action is beeing called twice with exactly the same Request object. It also seems that TYPO3\CMS\Extbase\Core\Bootstrap->run is being called twice.
When I track microtime_start, it shows both 'test' execution at the same request. So it must be duplicated during the same, initial, request, not after redirect.

Timestamp report:
microtime: 1587538537.343; microtime_start: 1587538536.5837; testAction
microtime: 1587538537.3866; microtime_start: 1587538536.5837; testAction
microtime: 1587538538.0774; microtime_start: 1587538537.4427; test2Action

I also did a try with manual redirect using php header function, to exactly the same URI, as I did using native Extbase redirect: no duplication occured.

I did another test, calling 'test2' action directly, and it only reported its request once in my log.

Actions #2

Updated by Michael Stopp almost 4 years ago

I can confirm this (for V9). In my case, I have an action that adds new objects to a repository and issues a flash message with the number of newly created objects. With every call of the action I get 2 flash messages and all objects are created twice. When I change the redirect to a forward, the problem goes away.

Actions #3

Updated by Michael Stopp almost 4 years ago

  • Related to Bug #88628: Redirect call on controller level is firing the action again added
Actions #4

Updated by Michael Stopp almost 4 years ago

This seems related to caching -> check out #88628. After switching my action to non-cacheable, I no longer get the double calls.

Actions #5

Updated by Benni Mack 8 months ago

  • Sprint Focus set to On Location Sprint
Actions

Also available in: Atom PDF