From 77a3e843f883b2f99b71197efd4d082742690ea6 Mon Sep 17 00:00:00 2001
From: Helmut Hummel <typo3@helhum.io>
Date: Sat, 28 Mar 2020 10:41:40 +0100
Subject: [PATCH] [BUGFIX] Skip input validation in scheduler command task

All commands that are added via Configuration/Commands.php
are instantiated and prepared when the "scheduler:run" command is
executed. This preparation includes setting the Application object.

If this Application object is present in an Command object,
calling the run method of the command will cause a merge
of the application's arguments with command arguments.

Since command objects in symfony/console and TYPO3 are
more or less singletons, these merged arguments will
stay merged on a second "instantiation" of the command
through when scheduler executes the second task with the same command.

Therefore we must SKIP the validation of the new Input object
we create and pass to the command's run method, so that this
validation does not fail due to the missing command argument.

It also does not matter that we skip validation, because validation
happens implicitly when calling the run method on the command object.
Only Symfony code is "smart" enough to set the command argument,
when it was not present before.

Resolves: #87312
Releases: master,9.5
Change-Id: I75677493216961fd7559a923e94e7831e07921bf
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63964
Tested-by: Helmut Hummel <typo3@helhum.io>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Manuel Selbach <manuel_selbach@yahoo.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
---
 .../scheduler/Classes/Task/ExecuteSchedulableCommandTask.php    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/scheduler/Classes/Task/ExecuteSchedulableCommandTask.php b/typo3/sysext/scheduler/Classes/Task/ExecuteSchedulableCommandTask.php
index fd71a69c1783..b1a4fccd074a 100644
--- a/typo3/sysext/scheduler/Classes/Task/ExecuteSchedulableCommandTask.php
+++ b/typo3/sysext/scheduler/Classes/Task/ExecuteSchedulableCommandTask.php
@@ -98,7 +98,7 @@ class ExecuteSchedulableCommandTask extends AbstractTask
             );
         }
 
-        $input = new ArrayInput($this->getParameters(false), $schedulableCommand->getDefinition());
+        $input = new ArrayInput($this->getParameters(false));
         $output = new NullOutput();
 
         return $schedulableCommand->run($input, $output) === 0;
-- 
GitLab