Review main Merged

80404[TASK] Introduce Symfony attribute based registration of CLI commands

Bastien Lutz CR +2 V +2 Normal +79 −0 updated 10/26/23, 21:47

Commit message

CLI commands had to be registered in the extensions `Services.yaml`
file with the `console.command` tag. This change enables automatic
cli command registration with the tag `console.command` by using
the existing `\Symfony\Component\Console\Attribute\AsCommand`
symfony PHP attribute. Thus providing an additional and simpler
way, without deprecating or enforcing to change already existing
registrations.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 5371

Show 3446 earlier messages
  1. Bastien Lutz uploaded patch set 1 08/05/23, 10:00

  2. core-ci voted on patch set 1 V +1 08/05/23, 10:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45103

  3. Stefan Bürk uploaded patch set 2 V +1 08/05/23, 14:59

  4. Stefan Bürk voted on patch set 2 V +1 CR +1 08/05/23, 15:01

  5. core-ci voted on patch set 2 V +1 08/05/23, 15:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45110

  6. Oli Bartsch commented on patch set 2 08/05/23, 16:24

    ConsoleCommand.php:24

    I propose to use `AsConsoleCommand`.
  7. Chris Müller commented on patch set 2 08/05/23, 17:14

    ConsoleCommand.php:24 Reply

    We have then "different" attributes: In v12 were introduced: - \TYPO3\CMS\Backend\Attribute\Controller - \TYPO3\CMS\Install\Attribute\UpgradeWizard When using the "As" prefix this gets inconsistent: Some has "As", some not.
  8. Stefan Bürk voted on patch set 2 V 0 CR 0 08/05/23, 18:06

  9. Oli Bartsch commented on patch set 2 08/05/23, 19:33

    ConsoleCommand.php:24 Reply

    Correct. I propose to use the As naming for all new attributes and to think of a migration path for the existing ones.
  10. Stefan Bürk commented on patch set 2 08/06/23, 16:45

    A note - this solves midterm the issue, that if some names are used in the description of a command and replaced in the yaml, it no longer produces weired descriptions output for the command listing/help.
  11. Mathias Brodala commented on patch set 2 08/07/23, 07:24

    Feature-101567-IntroducePHPAttributeToAutoconfigureCliCommands.rst:43

    This should be "AsConsoleCommand" to be consistent with the recently added "AsEventListener".
  12. Bastien Lutz uploaded patch set 3 V +1 08/07/23, 09:27

  13. Mathias Brodala updated the commit message in patch set 4 08/07/23, 09:31

  14. core-ci voted on patch set 3 V +1 08/07/23, 09:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45175

  15. core-ci voted on patch set 4 V +1 08/07/23, 09:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45176

  16. Chris Müller uploaded patch set 5 V +1 08/07/23, 10:07

  17. Chris Müller uploaded patch set 6 08/07/23, 10:08

  18. Chris Müller commented on patch set 6 08/07/23, 10:09

    ConsoleCommand.php:24 Reply

    Ack
  19. core-ci voted on patch set 6 V +1 08/07/23, 10:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45179

  20. core-ci voted on patch set 5 V +1 08/07/23, 10:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45178

  21. Bastien Lutz commented on patch set 6 08/09/23, 10:45

    ConsoleCommand.php:24 Reply

    Done

    Feature-101567-IntroducePHPAttributeToAutoconfigureCliCommands.rst:43 Reply

    Done
  22. Benjamin Franzke commented on patch set 6 CR -1 08/10/23, 08:50

    will review
    missing line: Releases: main
  23. Benjamin Franzke uploaded patch set 7 CR -1 V +1 08/10/23, 09:01

  24. Benjamin Franzke commented on patch set 7 08/10/23, 09:01

    Reply

    Done

    Reply

    Done
  25. core-ci voted on patch set 7 V +1 08/10/23, 09:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45316

  26. Jörg Bösche voted on patch set 7 V +1 CR +1 08/10/23, 12:54

  27. Benjamin Kott commented on patch set 7 09/14/23, 21:46

    please consider adding this, also to 12.4 this is marked as feature, yes - but in general it´s only a simple improvement to developers. Gating this away until v13 feels wrong to me.
  28. Garvin Hicking commented on patch set 7 09/15/23, 07:32

    Feature-101567-IntroducePHPAttributeToAutoconfigureCliCommands.rst:34

    Suggestion: "(all parameters as above are still viable: command, description, schedulable, hidden)"
  29. Garvin Hicking voted on patch set 7 V +1 CR +1 09/15/23, 07:43

  30. Bastien Lutz uploaded patch set 8 CR +1 V +1 09/19/23, 09:57

  31. core-ci voted on patch set 8 V -1 09/19/23, 10:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46750

  32. Bastien Lutz commented on patch set 8 09/19/23, 10:09

    Feature-101567-IntroducePHPAttributeToAutoconfigureCliCommands.rst:34 Reply

    As discussed in the typo3-cms-coredev channel i decided to use the symfonf shipped AsCommand Attribute. Therefore in order to overwrite schedulable or hidden the old way of registration is still accepted. A note was added to the rst file.
  33. Bastien Lutz uploaded patch set 9 V -1 09/19/23, 10:13

  34. Mathias Brodala commented on patch set 9 09/19/23, 10:20

    CLI
    Symfony
    commands

    Important-101567-UseSymfonyAttributeToAutoconfigureCliCommands.rst:19

    And this cannot be changed since the Symfony "AsCommand" attribute does not have these parameters, correct? If yes, then this should be emphasized and mentioned once more in the example below.
  35. core-ci voted on patch set 9 V +1 09/19/23, 10:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46752

  36. Garvin Hicking commented on patch set 9 09/19/23, 10:34

    Services.php:49

    Maybe for "future us" we could add a comment here like: // hidden, schedulable is not (yet?) a configurable symfony attribute parameter // If those parameters shall be set differently, services.yaml registration can be used // Note: If services.yaml registration gets deprecated at some point, another way of exposing a way to alter these attributes must be possible. (maybe a shorter variant of this)
  37. Mathias Brodala commented on patch set 9 09/19/23, 10:44

    Services.php:49 Reply

    At least "hidden" exists in Symfony, so that would work as expected: https://github.com/symfony/symfony/blob/4ba165a7e2c1a9bcdca69393e7fef8f25a66f8ea/src/Symfony/Component/Console/Attribute/AsCommand.php#L24 Maybe could consider adding a custom attribute "AsSchedulerTask" which would cover the "schedulable: true" case. If absent, "schedulable: false" could be implied.
  38. Bastien Lutz updated the commit message in patch set 10 V +1 09/19/23, 11:48

  39. Bastien Lutz commented on patch set 10 09/19/23, 11:48

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Services.php:49 Reply

    Hidden can not be used as it is protected. I think providing multiple attributes for this simple registration would over complicate this and may be confusing. Adding a comment for our "future us" sounds reasonable i'll add a comment with the next patchset

    Important-101567-UseSymfonyAttributeToAutoconfigureCliCommands.rst:19 Reply

    Correct. They are not provided. As already discussed on slack the "old" way via Services.yaml should be used if a dev wants to overwrite them.
  40. Bastien Lutz uploaded patch set 11 09/19/23, 11:52

  41. core-ci voted on patch set 10 V +1 09/19/23, 11:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46767

  42. core-ci voted on patch set 11 V +1 09/19/23, 12:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46768

  43. Bastien Lutz updated the commit message in patch set 12 V +1 09/19/23, 12:07

  44. core-ci voted on patch set 12 V +1 09/19/23, 12:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46772

  45. Benjamin Franzke commented on patch set 12 09/19/23, 12:48

    Services.php:48

    Services.yaml

    Services.php:49 Reply

    ack, I think it's fine for the rare case for non schedulable commands to be required to use Services.yaml
  46. Stefan Bürk commented on patch set 12 09/19/23, 16:46

    Services.php:49 Reply

    FYI - for me, having scheduable commands are the "rare case". 100% of may commands I created and project and internal projects are mostly long running tasks and not suited to be scheduled as scheduler task. rare case for me would be to have schedulable commands. Makes the decision harder here. Maybe we should keep that here with false, and for v13 a core implementation attrobute which supports it then. However, not blocking it. But also not really voting it as I'm quite unsure if this is really the right default.
  1. Benjamin Franzke commented on patch set 12 10/26/23, 06:46

    Services.php:49 Reply

    I'd say long-running tasks are still "fine" to be scheduled. scheduler is a task runner. IMO "schedulable:false" main usage is to define: This command cannot run without user interaction – e.g. it needs your input/action during runtime. …and I think that's a rare case. Would you be fine with that definition?
  2. Stefan Bürk commented on patch set 12 10/26/23, 10:59

    Services.php:49 Reply

    I'm still disagree. From personal experience my commands mostly did not need to be schedualable, and often would lead to unexpected behaviour if the command would have been configured to be scheduled and executed in the web contect and not from cli running the scheduler command. My point is just, that there is no real good default as it differs from person/project to another which would be the "correct" default. My comment was more a FYI and not meant as blocking. Therefore, fine with your "definition" as we would otherwise end a dead end.
  3. Stefan Bürk rebased onto patch set 13 V +1 10/26/23, 10:59

  4. core-ci voted on patch set 13 V +1 10/26/23, 11:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48225

  5. Stefan Bürk commented on patch set 14 V +1 10/26/23, 11:12

    Published edit on patch set 13.
  6. Stefan Bürk commented on patch set 14 10/26/23, 11:13

    Services.php:48 Reply

    Done
  7. Benni Mack commented on patch set 14 10/26/23, 11:18

    Services.php:49 Reply

    most of my scheduler tasks are wrapped in a CLI Command, I recommend to slowly dissolve scheduler tasks that can't be run directly on CLI. So, my from experience, roughly 60-80% of my project Cli commands are schedulable.
  8. core-ci voted on patch set 14 V +1 10/26/23, 11:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48227

  9. Benjamin Franzke updated the commit message in patch set 15 V +1 10/26/23, 11:22

  10. Benjamin Franzke voted on patch set 15 CR -1 10/26/23, 11:23

  11. Benjamin Franzke uploaded patch set 16 CR -1 10/26/23, 11:29

  12. core-ci voted on patch set 15 V +1 10/26/23, 11:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48228

  13. Benjamin Franzke voted on patch set 16 V +1 CR +1 10/26/23, 11:29

  14. core-ci voted on patch set 16 V +1 10/26/23, 11:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48229

  15. Garvin Hicking voted on patch set 16 V +1 CR +1 10/26/23, 12:04

  16. Stefan Bürk voted on patch set 16 V +1 CR +1 10/26/23, 14:49

  17. Stefan Bürk voted on patch set 16 V +2 CR +2 10/26/23, 21:13

  18. Stefan Bürk updated the commit message in patch set 17 CR +1 V +1 10/26/23, 21:26

  19. Stefan Bürk updated the commit message in patch set 18 10/26/23, 21:27

  20. Stefan Bürk commented on patch set 18 V +1 CR +1 10/26/23, 21:27

    Commit message was a little off. Beside that, I already created the backport. Waiting for revotes before merge.
  21. core-ci voted on patch set 17 V +1 10/26/23, 21:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48265

  22. core-ci voted on patch set 18 V +1 10/26/23, 21:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48266

  23. Garvin Hicking voted on patch set 18 V +1 CR +1 10/26/23, 21:44

  24. Stefan Bürk voted on patch set 18 V +2 CR +2 10/26/23, 21:46

  25. Stefan Bürk merged patch set 19 10/26/23, 21:47