Review main Abandoned

90852[FEATURE] "Ad-hoc" tasks for CLI scheduler

Garvin Hicking CR 0 V 0 Hard +588 −1 updated 10/17/25, 11:50

Commit message

With #106532 we are now able to run ad-hoc tasks from the CLI,
without the need to first persist tasks in the database.

This removes the need to convert all AbstractTasks to
Symfony Commands, so that we can support:

* Ad-hoc tasks to run arbitrary tasks on CLI
* Symfony Commands on CLI
* Regular tasks for Scheduler
* Symfony Commands as schedulable tasks

Example execution:

  vendor/bin/typo3 scheduler:adhoc:execute  \
    --task 'TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask' \
    --config='{"selected_tables": "be_dashboards,be_groups"}'

Review

  • Code review CR 0
  • Verified V 0
    • core-ci +1 CI

Issues 2

Files 11

Review log 1724

  1. Garvin Hicking uploaded patch set 1 10/01/25, 08:05

  2. core-ci voted on patch set 1 V -1 10/01/25, 08:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85784

  3. Garvin Hicking uploaded patch set 2 V -1 10/01/25, 08:21

  4. core-ci voted on patch set 2 V +1 10/01/25, 08:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85787

  5. Garvin Hicking uploaded patch set 3 V +1 10/04/25, 08:22

    Adjust variable names
  6. core-ci voted on patch set 3 V +1 10/04/25, 08:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85988

  7. Benni Mack commented on patch set 3 10/04/25, 14:32

    hey, how about creating a new command "scheduler:adhoc:run" this way, we don't need to do --adhoc over and over again?
  8. Oli Bartsch commented on patch set 3 10/04/25, 14:39

    Reply

    ++
  9. Garvin Hicking commented on patch set 3 10/04/25, 14:51

    Reply

    Yeah. Tomatoes on the eyes. Will do.
  10. Garvin Hicking uploaded patch set 4 V +1 10/04/25, 19:50

    Move to own scope tests list command
  11. Garvin Hicking commented on patch set 4 10/04/25, 19:54

    Reply

    Done

    TaskService.php:75

    Reviewer's note: I wanted to be able to type-hint the CLI output at least somehow, and did not want to jump through all the TCA hoops inside the CLI command to evaluate which TCA type a field has.

    Services.yaml:31

    Reviewer's note: These are not using the #[AsCommand] attributes intentionally. These would always be schedulable, which we don't want, because of recursion because of recursion.
  12. core-ci voted on patch set 4 V -1 10/04/25, 19:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86017

  13. Garvin Hicking commented on patch set 5 V -1 10/04/25, 20:24

    Published edit on patch set 4.
  14. core-ci voted on patch set 5 V -1 10/04/25, 20:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86019

  15. core-ci voted on patch set 5 V +1 10/04/25, 20:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86019

  16. Garvin Hicking updated the commit message in patch set 6 V +1 10/04/25, 21:01

  17. core-ci voted on patch set 6 V +1 10/04/25, 21:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86020

  18. Chris Müller commented on patch set 6 10/05/25, 04:19

    SchedulerAdHocExecuteCommand.php:49

    Wouldn't it be better to register an argument instead of an option for the task? The task is mandatory anyway, and this way one can omit the "--task" part then: typo3 scheduler:adhoc:execute \ 'TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask' \ --config='{"selected_tables": "be_dashboards,be_groups"}'
  19. Garvin Hicking commented on patch set 6 10/05/25, 06:53

    SchedulerAdHocExecuteCommand.php:49 Reply

    I did think about this but I thought maybe we would later add interaction to the command and then it would not be a mandatory argument anymore and we would need to change docs. With the option we can make it not required any time. Does that sound reasonable? Open to discussion.
  20. Oli Bartsch commented on patch set 6 10/05/25, 08:13

    SchedulerAdHocExecuteCommand.php:49 Reply

    I would also see this as an required argument for this command.

    TaskService.php:75

    What is this used for?
  21. Benni Mack commented on patch set 6 10/05/25, 08:43

    Feature-107575-AdHocTasksForSchedulerCLI.rst:20

    we should debate if this CLI command should actually create a new tx_scheduler_task record which is set to "single run" and executed directly. Why? Because then we'd have logging etc. what is executed and when with what options.

    Feature-107575-AdHocTasksForSchedulerCLI.rst:27

    Let's discuss this (recommendation for today). I see a downside for this recommendation nowadays - you can have extended validation and better UX for configuring a native scheduler task than a CLI command. "also allowed CLI execution" scheduler tasks always allowed CLI executions.
  22. Garvin Hicking commented on patch set 6 10/05/25, 13:00

    Feature-107575-AdHocTasksForSchedulerCLI.rst:20 Reply Unresolved

    Hm. I could imagine we could log it, but creating a DB entry and removing that again would feel like spamming the DB and would be unexpected to me. It also makes the "ad-hocness" be a moot point. So, to me, I'd prefer not to, and just to loggerInterface stuff.

    Feature-107575-AdHocTasksForSchedulerCLI.rst:27 Reply Unresolved

    Yeah but you had to create a task and run it on CLI and that was awkward, so the symfony command was much more convenient. Also IMO the Symfony command validations are more common and standard than the task TCA/Formengine validation. We could of course also just remove the "this is still recommended" and see what the actual best practice will evolve to?! I have no strong oppinion here.

    SchedulerAdHocExecuteCommand.php:49 Reply Unresolved

    The regular "scheduler:execute" also has the task as an option and not an argument. Multiple options can also be chained here. The more I think about it we shouldn't block ourselves with an argument here instead of an option we can handle/adjust better in the future.

    TaskService.php:75 Reply Unresolved

    Please see resolved command comment. It's there to reveal the TCA type of a field on the CLI "list" command.
  23. Garvin Hicking commented on patch set 6 10/17/25, 11:50

    Unresolved

    I've received feedback that the ideal way to proceed with this is: * Migrate the logic of all TYPO3 Core Tasks into Service classes * Add a Symfony CLI Command to execute the logic from the service class, using Symfony CLI options * Adjust the Native Task to run logic from the Service class, using TCA options This would be the clean approach, but maybe not the pragmatic one. Due to this I've extracted this as a third-party extension: https://github.com/garvinhicking/typo3-adhoc-tasks/ I am abandoning this patch because I feel this will not gain traction here, and I understand and support the reasoning. However, this also means: More work. :-D
  24. Garvin Hicking abandoned the change 10/17/25, 11:50

    Abandoning, see comment.