Review main Merged

88082[BUGFIX] Prevent duplicate user group creation

Lina Wolf CR +2 V +2 Normal +142 −26 updated 03/02/25, 09:14

Commit message

A user group will no longer be created if one
with the same name already exists, unless the
new `--force` option is specified.

This prevents accidental duplicate user group
creation when the command is run multiple times
unintentionally.

Add a test to ensure this behaviour

Review

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

Issues 1

Files 5

Review log 2634

Show 79 earlier messages
  1. Lina Wolf uploaded patch set 1 02/07/25, 14:33

  2. core-ci voted on patch set 1 V -1 02/07/25, 14:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73737

  3. Lina Wolf uploaded patch set 2 V -1 02/07/25, 14:49

  4. core-ci voted on patch set 2 V +1 02/07/25, 14:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73742

  5. Andreas Wolf voted on patch set 2 CR +1 V +1 02/07/25, 20:52

  6. Oliver Wand voted on patch set 2 CR +1 02/08/25, 09:27

  7. Lina Wolf marked it work in progress 02/08/25, 10:08

  8. Lina Wolf commented on patch set 2 02/08/25, 10:08

    This change is ready for review.
    I talked to Stefan Bürk and will add a test before proceeding
  9. Lina Wolf marked it work in progress 02/08/25, 10:08

  1. Lina Wolf uploaded patch set 3 CR +1 V +1 02/08/25, 12:09

  2. Lina Wolf commented on patch set 3 02/08/25, 12:10

    This change is ready for review.
    Added a test, please resume review
  3. core-ci voted on patch set 3 V +1 02/08/25, 12:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73801

  4. Garvin Hicking commented on patch set 3 V +1 02/08/25, 20:49

    (Verified to work, only quick-read the code, waiting for Stefan to give feedback on tests. I think this one is worth having, duplicate user groups should not be the default)
  5. Stefan Bürk voted on patch set 3 CR -1 02/08/25, 21:38

  6. Stefan Bürk commented on patch set 3 02/26/25, 09:27

    I'm fine with the change in general, also with adding an additional flag as bugfix on backport. TBH not sure if that would require a go from Benni, but I guess not as this should be safe to be done. Looking on the implementation details, I have some remarks. See other comments.

    SetupDefaultBackendUserGroupsCommand.php:63

    Can we rephrase that to emphasize that this forces to create NEW record(s) with the same name ?

    SetupDefaultBackendUserGroupsCommand.php:116

    ```suggestion if ($messages !== [) { ```

    SetupService.php:362

    ```suggestion private function countBackendGroupsByTitle(ConnectionPool $connectionPool, string $title): int ```

    SetupService.php:365

    ```suggestion return (int)$queryBuilder->count('*') ``` Helps with phpstan when rising levels at some point. Humans know that this may always return an integer, but static code analyzers would assume int|false which is not compatible in the long run. I'd prefere the explicit int cast here.

    SetupServiceTest.php:32

    ```php protected bool $initializeDatabase = true; ``` This is superflous as it is the default.

    SetupServiceTest.php:42

    ```suggestion $subject = $this->get(SetupService::class); ``` What is the reason to mock all these stuff within a functional test ? I rather tend to use the real services here. Same for the other testcase methods.

    SetupServiceTest.php:44

    Instead of a "count" I'd suggest to use the `assertCSVDataSet()` along with a csv fixture file to not only test the pure count but real table contents with fields and uids. Same for other testcase method, special the last one with "pre existing" records before and after the setupservice execution. Using the csv assertion would also allow that the settings contained in the csv are added - eventually. Not sure if we should do that here.
  7. Lina Wolf uploaded patch set 4 CR -1 V +1 02/26/25, 09:54

  8. Lina Wolf commented on patch set 4 02/26/25, 09:54

    SetupDefaultBackendUserGroupsCommand.php:63 Reply

    Done

    SetupDefaultBackendUserGroupsCommand.php:116 Reply

    Done

    SetupService.php:362 Reply

    Done

    SetupServiceTest.php:32 Reply

    Done
  9. Lina Wolf marked it work in progress 02/26/25, 09:54

  10. Lina Wolf commented on patch set 4 02/26/25, 09:58

    This change is ready for review.

    SetupService.php:365 Reply

    `fetchOne()` actually returns mixed and casting mixed to int does not work below a certain level of phpstan. But I think casting to (int) does no harm here, so I applied it.

    SetupServiceTest.php:44 Reply

    In my feeling this would be a little out of context within this PR as I would be testing functionallity that was not added by this PR.
  11. core-ci voted on patch set 4 V +1 02/26/25, 10:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74739

  12. Lina Wolf marked it work in progress 02/27/25, 13:49

  13. Lina Wolf uploaded patch set 5 V +1 02/27/25, 14:15

  14. Lina Wolf uploaded patch set 6 02/27/25, 14:17

  15. core-ci voted on patch set 5 V -1 02/27/25, 14:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74837

  16. core-ci voted on patch set 6 V -1 02/27/25, 14:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74838

  17. Stefan Bürk uploaded patch set 7 V -1 02/28/25, 10:37

  18. core-ci voted on patch set 7 V +1 02/28/25, 10:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74888

  19. Stefan Bürk uploaded patch set 8 V +1 02/28/25, 10:56

  20. core-ci voted on patch set 8 V +1 02/28/25, 11:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74890

  21. Stefan Bürk commented on patch set 8 CR +1 V +1 02/28/25, 11:11

    This change is ready for review.

    SetupServiceTest.php:42 Reply

    Done

    SetupServiceTest.php:44 Reply

    This was slightly a both-side missunderstating and has been solved with a slack huddle with Lina. I wanted to use `assertCSVDataSet()` directly here as check on more specified records instead of simple counts. My addition for the specific content was only ment as a general "we may want to extend the tests on a already existing feature based on db level" and did not expressed correctly that this is something for an eventually followup. `Not sure if we should do that here.` Did not emphasized that enough. @112@linawolf.de reworked the code based on my comment, thanks for taking care. Resolving this comment now.
  22. Garvin Hicking voted on patch set 8 CR +1 V +1 02/28/25, 11:38

  23. Christian Kuhn voted on patch set 8 CR +1 V +1 03/02/25, 01:29

  24. Garvin Hicking voted on patch set 8 CR +2 V +2 03/02/25, 07:38

  25. Garvin Hicking merged patch set 9 03/02/25, 09:14