Review main Merged

82822[BUGFIX] Create backend users via CLI respects TCA default options

Lukas Maxheim CR +2 V +2 Hard +274 −15 updated 04/07/24, 12:04

Commit message

This change introduces the use of the DataHandler instead of the
QueryBuilder when creating backend users via CLI command
`backend:user:create`.

This ensures that the user is initialized with TCA default options and
the creation and history of the new user is logged to the TYPO3 log.

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 6

Review log 4256

Show 2231 earlier messages
  1. Lukas Maxheim uploaded patch set 1 02/06/24, 14:02

  2. core-ci voted on patch set 1 V +1 02/06/24, 14:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52794

  3. Stefan Bürk commented on patch set 1 02/07/24, 16:52

    Thanks for your patch. Please read the contribution guide regarding rules for the commit message. You exceeding the max line length and fix your commit message. I'd say the bullet-list style is not needed, so remove that to and keep the sentances as is in some way. Out-of-scope - I'd question why the user creation is done with plain QueryBuilder at all and not using the `DataHandler`. Currently no time, but I would investigate first why this is done and consider if it would not be wiser to switch to that. Therefore, all default for columns are used anyway. TBH - not sure if this could work, but would be a general thing here. Otherwise, your approach looks at least good for the current implementation with the QueryBuilder insert.
  4. Lukas Maxheim updated the commit message in patch set 2 V +1 02/07/24, 17:06

  5. core-ci voted on patch set 2 V +1 02/07/24, 17:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52869

  6. Lukas Maxheim commented on patch set 2 02/07/24, 17:20

    I am quite new to the process and just wanted to stick to the scope of the referenced issue, so thank you for your feedback - especially for the DataHandler approach. I shortened the commit message/description to match the requirements from the contribution guide.
  7. Lukas Maxheim commented on patch set 2 02/07/24, 17:26

    Reply

    Done
  8. Stefan Bürk commented on patch set 2 02/07/24, 21:01

    Reply

    Got that, and from that point of view that is okay and the way you provided that change. I mentioned the fact with the DataHandler and my thoughts for other reviewers and from a maintainer point of view as a general note - to think about it (not for you to take action for now). Will revisit and check that deeper the next days I hope, at least it is documented if some else from the casual reviewes/contributiors or core team members have a peak and have time to look into a eventually more suitable approach before I have it. Every thing done right so far (commit message aside).
  9. Stefan Bürk updated the commit message in patch set 3 V +1 02/07/24, 21:01

  10. core-ci voted on patch set 3 V +1 02/07/24, 21:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52870

  11. Benni Mack commented on patch set 3 CR -1 02/12/24, 14:17

    CreateBackendUserCommand.php:343

    I think we need to use DataHandler here, so we can also log this / have a history entry that this record was created.
  12. Lukas Maxheim commented on patch set 3 02/12/24, 14:22

    CreateBackendUserCommand.php:343 Reply

    Acknowledged
  13. Lukas Maxheim uploaded patch set 4 CR -1 V +1 02/13/24, 11:47

  14. Lukas Maxheim uploaded patch set 5 02/13/24, 11:53

  15. core-ci voted on patch set 4 V +1 02/13/24, 11:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53165

  16. core-ci voted on patch set 5 V +1 02/13/24, 11:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53166

  17. Mathias Brodala commented on patch set 5 CR -1 02/13/24, 12:57

    CreateBackendUserCommand.php:347

    You can use the incoming plain-text password here, the DataHandler takes care of hashing. (See DataHandler::checkValueForPassword())

    CreateBackendUserCommand.php:350

    We can pass through the incoming array here, the DataHandler can handle this.
  18. Lukas Maxheim uploaded patch set 6 CR -1 V +1 02/13/24, 13:05

  19. Lukas Maxheim commented on patch set 6 02/13/24, 13:07

    CreateBackendUserCommand.php:347 Reply

    Thanks for the feedback, i updated this.

    CreateBackendUserCommand.php:350 Reply

    Thanks for the feedback, i updated this.
  20. core-ci voted on patch set 6 V -1 02/13/24, 13:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53170

  21. Lukas Maxheim uploaded patch set 7 V -1 02/13/24, 13:13

  22. Lukas Maxheim uploaded patch set 8 02/13/24, 13:16

  23. core-ci voted on patch set 7 V -1 02/13/24, 13:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53171

  24. core-ci voted on patch set 8 V +1 02/13/24, 13:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53172

  25. Mathias Brodala commented on patch set 8 CR -1 02/13/24, 13:48

    CreateBackendUserCommand.php:339

    How about "$userId" ...

    CreateBackendUserCommand.php:359

    This can be reduced: $userId = $dataHandler->substNEWwithIDs[$userId] ?? null;
  26. Lukas Maxheim uploaded patch set 9 CR -1 V +1 02/13/24, 13:54

  27. Mathias Brodala commented on patch set 9 CR +1 02/13/24, 13:57

    CreateBackendUserCommand.php:339 Reply

    Done

    CreateBackendUserCommand.php:359 Reply

    Done
  28. Lukas Maxheim commented on patch set 8 02/13/24, 13:57

    CreateBackendUserCommand.php:339 Reply

    In my opinion the variable name is more precise, so I would keep it.

    CreateBackendUserCommand.php:359 Reply

    Done
  29. core-ci voted on patch set 9 V +1 02/13/24, 13:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53175

  30. Garvin Hicking commented on patch set 9 CR +1 V -1 02/16/24, 15:44

    This generally looks good, however - the users created with that command are now disabled by default. This is probably because the "default" in the TCA for "disable" is "1". Thus I think a "disable = 0" should be passed here?
  1. Lukas Maxheim commented on patch set 9 02/16/24, 15:52

    Reply

    I appreciate your feedback. In my opinion this should respect TCA defaults regarding the initial scope - but i can add it.
  2. Garvin Hicking commented on patch set 9 02/16/24, 16:19

    Reply

    This is indeed a pickle. I'd argue that the CLI command needs to create a working user account. So the alternative would be to add a parameter option to indicate the disable/enabled state to override this? (BTW: Note https://review.typo3.org/c/Packages/TYPO3.CMS/+/83018 - currently, shortcut options are broken, found this out while testing your patch :))
  3. Lukas Maxheim uploaded patch set 10 CR +1 V +1 02/19/24, 07:45

  4. Lukas Maxheim commented on patch set 10 02/19/24, 07:47

    Reply

    Done.
  5. core-ci voted on patch set 10 V +1 02/19/24, 07:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53325

  6. Garvin Hicking commented on patch set 10 CR +1 V +1 02/19/24, 08:03

    Thanks! ☺️
  7. Andreas Kienast commented on patch set 10 CR -1 02/26/24, 12:50

    CreateBackendUserCommand.php:349

    AFAICS the database column name is `disable`. Also, this command behaves differently than the user creation in the backend, as new users are disabled by default. What is the reason to ignore the TCA default here?
  8. Andreas Kienast commented on patch set 10 V -1 02/26/24, 12:56

    CreateBackendUserCommand.php:349 Reply

    As I suspected - `disabled` is an invalid field, hence DataHandler ignores it. TCA default of `disable` kicks in and the user is disabled upon creation.
  9. Lukas Maxheim uploaded patch set 11 CR +1 V +1 02/26/24, 13:20

  10. core-ci voted on patch set 11 V +1 02/26/24, 13:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53614

  11. Lukas Maxheim commented on patch set 11 02/26/24, 13:31

    CreateBackendUserCommand.php:349 Reply

    You are completely right - i updated this to `disable` and can verify it. Sorry for this! I stated that the original scope should be respected but i updated the behaviour to take @gh@faktor-e.de 's feedback into account: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82822/comments/453dfb8b_0d32d811 Should I undo this approach or should it stay as it is?
  12. Andreas Kienast commented on patch set 11 V +1 02/26/24, 15:26

    CreateBackendUserCommand.php:349 Reply

    tbh, I'm not sure. Anyway, the patch is fully functional now.
  13. Garvin Hicking commented on patch set 11 CR +1 V +1 02/26/24, 15:54

    I'd really be expecting a working BE account when using the CLI, otherwise it would be a Breaking Change. That could also happen of course but would need an RST file then and couldn't backport to v12... and we should then have an option to the CLI to toggle disable=1 if wanted? Voting for the current implementation 😇 (I sadly tested it wrongly, sorry for missing the "disabled" key and thanks for noticing!)
  14. Stefan Bürk commented on patch set 11 CR -1 02/27/24, 20:32

    I guess it's time to cover this cli command with some tests. Especially after the culprit with the `disabled <-> disable` field name. The `ext:core` has a abstract command tester class and also provides some command tests, for example https://github.com/TYPO3/typo3/blob/d2964e387186a9832dc259662f334c5def8c2dae/typo3/sysext/core/Tests/Functional/Command/CacheWarmupCommandTest.php#L26 With the different options and using `assertCsvDataset()` with csv fixtures afterward. Also different TCA presets can be tested if they are really taking into account and so on. What do you think ? Are you up to add some tests for the command ? Unrelated to this change - personally I prefere to keep commands slim and clean and handle stuff in services, but that's another topic to refactor eventually.
  15. Lukas Maxheim commented on patch set 11 02/29/24, 09:31

    Reply

    Yes this makes totally sense - i can tackle this.
  16. Garvin Hicking uploaded patch set 12 CR +1 V +1 04/05/24, 12:55

    Add tests
  17. Garvin Hicking commented on patch set 12 CR +1 V +1 04/05/24, 12:57

    Reply

    I took the liberty to add tests to this patch, hopefully covering most issues that can be faced. I'd be happy if you can have a look at it and see if that's a viable approach. I do not specifically cover checking the sys_log and other things the DataHandler does, because that is covered by the DataHandler tests.
  18. core-ci voted on patch set 12 V +1 04/05/24, 12:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55383

  19. Stefan Bürk uploaded patch set 13 CR +1 V +1 04/07/24, 10:39

  20. core-ci voted on patch set 13 V -1 04/07/24, 10:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55500

  21. Stefan Bürk uploaded patch set 14 V -1 04/07/24, 10:49

  22. core-ci voted on patch set 14 V +1 04/07/24, 10:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55501

  23. Garvin Hicking voted on patch set 14 CR +1 V +1 04/07/24, 11:09

  24. Stefan Bürk commented on patch set 14 CR +2 V +2 04/07/24, 11:15

    Reply

    Thanks Garvin for taking care of the requested tests. I moved them to `EXT:backend` which provides the tested command.

    CreateBackendUserCommand.php:349 Reply

    I get Andreas point here, but I'd say that this needs to be reconsidered in a follow up change along with a `enforce-enable` options or similar. It make sense to have the TCA default for backend user creation with a `disabled` default state, but the command is also used for (test pipeline) distribution or automatic instance deployments / creation and having the ability to create them `enabled` make sense. Due to the usage of direct database inserts, the database default (disabled = 0) has been used and adding a `disabled = 0` to the datahandler datamap respects this. Considering a change here is out-of-scope of this change, and would also eliminate the ability to backport it. Closing this now here, as the patch works now correctly in respect of what can and should be expected for this move.
  25. Stefan Bürk merged patch set 15 04/07/24, 12:04