#91156Double Action execution if redirect at its end
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;
}
}
?>Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Related issues 1
History 8
-
Michael Stopp commented <span data-processor="relativetime" data-value="2020-06-16T19:27:33+00:00" > 06/16/20, 19:27 </span>
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.
-
Michael Stopp changed Related to #88628 <span data-processor="relativetime" data-value="2020-06-16T19:43:39+00:00" > 06/16/20, 19:43 </span>
-
Michael Stopp commented <span data-processor="relativetime" data-value="2020-06-16T19:45:29+00:00" > 06/16/20, 19:45 </span>
This seems related to caching -> check out #88628. After switching my action to non-cacheable, I no longer get the double calls.
-
Benni Mack changed Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2023-08-02T14:54:48+00:00" > 08/02/23, 14:54 </span>
-
Benni Mack commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-02-28T18:56:46+00:00" > 02/28/25, 18:56 </span>Hey all,
yes, this problem exists due to the fact that I assume this plugin / action is cached. This way, the cached result is also executed / shown. This is a conceptual change, but IMHO a correct one.
Do you think we should change anything / document this or do you have any room for improvements here?
-
Benni Mack changed Sprint Focus
On Location Sprint<span data-processor="relativetime" data-value="2025-05-05T16:09:24+00:00" > 05/05/25, 16:09 </span> -
Garvin Hicking commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2026-11-09T18:17:15+00:00" > 11/09/26, 18:17 </span>Connection lost. Timeout after 189.216.000 seconds.
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.