Review main Merged

85586[BUGFIX] Replace method returnWebmounts() with getWebmounts()

Thomas Hohn CR +2 V +2 Normal +41 −14 updated 08/13/24, 11:55

Commit message

The method BackendUserAuthentication::returnWebmounts() returns
an array of strings. This triggers a type error when calling
DatabaseIntegrityController::getTreeList() since this method
now requires the mountpoint as an integer.

In order to keep backwards compatibility a new method
BackendUserAuthentication::getWebmounts() has been introduced,
which returns an array of integers.

Existing calls to returnWebmounts() have been replaced by calls
to getWebmounts() and fixes by applying array_map(intval(...)
on the result is now superfluous.

A follow up issue has been created #104607 to deprecate method
returnWebmounts() and to investigate if	succesive calls	to
array_unique can be done in getWebmounts() and removed.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Garvin Hicking +1
    • Andreas Kienast +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Andreas Kienast +1
    • core-ci +1 CI

Issues 2

Files 10

Review log 3848

Show 1823 earlier messages
  1. Thomas Hohn uploaded patch set 1 08/12/24, 08:04

  2. Thomas Hohn updated the commit message in patch set 2 08/12/24, 08:09

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

  4. Thomas Hohn commented on patch set 2 08/12/24, 08:21

    Hi - add you since you added types to getTreeList ;-)
  5. Andreas Kienast commented on patch set 2 08/12/24, 08:22

    Why can't we return a sanitized result from `returnWebmounts()`? That would be the proper solution to me.
  6. Thomas Hohn commented on patch set 2 08/12/24, 08:29

    Reply

    I guess this would be a breaking change since it's available via $GLOBALS['BE_USER']->returnWebmounts(). The method is public in BackendUserAuthentication. I can make an issue for TYPO3 14 to clean it up
  7. Ayke Halder updated the commit message in patch set 3 V +1 08/12/24, 08:43

  8. core-ci voted on patch set 3 V +1 08/12/24, 08:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63208

  9. Andreas Kienast commented on patch set 3 08/12/24, 10:08

    Reply

    Done
  10. Thomas Hohn uploaded patch set 4 V +1 08/12/24, 12:22

  11. core-ci voted on patch set 4 V +1 08/12/24, 12:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63226

  12. Andreas Kienast commented on patch set 4 08/12/24, 12:35

    BackendUserAuthentication.php:907

    `GeneralUtility::intExplode()` might be suitable here.
  13. Thomas Hohn uploaded patch set 5 V +1 08/12/24, 12:46

  14. Andreas Kienast commented on patch set 5 08/12/24, 12:51

    BackendUserAuthentication.php:901

    Why do we need to wait for v14? Adding this now isn't breaking.

    BackendUserAuthentication.php:907 Reply

    Done
  15. core-ci voted on patch set 5 V +1 08/12/24, 12:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63232

  16. Thomas Hohn uploaded patch set 6 V +1 08/12/24, 13:00

  17. core-ci voted on patch set 6 V +1 08/12/24, 13:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63237

  18. Thomas Hohn commented on patch set 6 08/12/24, 13:17

    BackendUserAuthentication.php:901 Reply

    Fine with me then ;-)
  19. Andreas Kienast voted on patch set 6 CR +1 08/12/24, 13:40

  20. Benni Mack voted on patch set 6 CR +1 08/12/24, 18:17

  21. Garvin Hicking commented on patch set 6 08/12/24, 20:36

    I hope I'm not blaming myself (again), it's still warm here: `isWebMount()` of `typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php` does this: ``` return in_array($this->identifier, $this->backendUser->returnWebmounts()); ``` and `$this->identifier` according to `typo3/sysext/backend/Classes/ContextMenu/ItemProviders/AbstractProvider.php` says "clicked record identifier (usually uid or file combined identifier)". That "combined identifier" makes me stumble. Is there a way that a string could be (validly) be passed by this and might lead to being cast as an invalid integer then? BTW: In the TYPO3 code search I found 5 public extensions (pagetreefilter, news, calendarize, ai_suite, address) that use `returnWebMounts`. Most of them alread use array_map() on their own, and those that do not should not face a regression with getting an int at least.
  22. Thomas Hohn commented on patch set 6 08/13/24, 04:40

    Reply

    Hi @gh@faktor-e.de So I believe the $this->identifier should and must be a uid in the PageProvider case - I can't see why it work otherwise. Assuming that the mount points are uid's I see no case where the provided patch should change that behaviour. The class FileProvider also extends the AbstractProvider and I believe that in that case the identifier could be a combined identifier - but I see no reason why this patch affects that case - since the comparison is done in the PageProvider class.
  23. Thomas Hohn updated the commit message in patch set 7 CR +1 V +1 08/13/24, 06:09

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

  2. Andreas Kienast commented on patch set 7 08/13/24, 06:55

    TreeController.php:524

    I just noticed we have subsequent calls to `array_unique()` quite often. Do you think it makes sense to incorporate this in `returnWebmounts()` as well?
  3. Oliver Hader commented on patch set 7 08/13/24, 07:05

    Why not just fixing this in `\TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController::getSelectQuery`? The chances are high, that changing the return type of `$beUser->returnWebmounts()` would break other individual implementations. We could introduce a new `getWebmounts()` returning `list<int>` (and optionally deprecate the existing `returnWebmounts()`).
  4. Thomas Hohn commented on patch set 7 08/13/24, 07:06

    TreeController.php:524 Reply

    Hi - I think we should make a follow up issue fixing that, since it might require an more in depth analysis of that.
  5. Oliver Hader commented on patch set 7 CR -1 08/13/24, 07:06

    I'm rather -1 on the change, since it might have negative side effects...
  6. Thomas Hohn commented on patch set 7 08/13/24, 07:16

    Reply

    I think the correct fix is to fix returnWebmounts. I have no problem in introducing a new method getWebmounts and keep returnWebmounts. I think a follow up issue could deprecate and fix the array_unique() issue
  7. Thomas Hohn uploaded patch set 8 CR -1 V +1 08/13/24, 07:46

  8. core-ci voted on patch set 8 V +1 08/13/24, 07:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63278

  9. Thomas Hohn commented on patch set 8 08/13/24, 07:51

    Reply

    Hi - did as proposed at created a follow up issue #104607 for deprecating the returnWebmounts method

    TreeController.php:524 Reply

    Create the follow up issue #104607
  10. Oliver Klee commented on patch set 8 08/13/24, 09:14

    BackendUserAuthentication.php:900

    We can make the return type more explicit here: ``` @return list<numeric-string> ```

    BackendUserAuthentication.php:915

    We can be even more specific: ``` @return list<int> ```
  11. Thomas Hohn uploaded patch set 9 V +1 08/13/24, 09:25

  12. Thomas Hohn commented on patch set 9 08/13/24, 09:25

    Reply

    Done

    BackendUserAuthentication.php:900 Reply

    Done

    BackendUserAuthentication.php:915 Reply

    Done
  13. core-ci voted on patch set 9 V +1 08/13/24, 09:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63285

  14. Oliver Klee commented on patch set 9 08/13/24, 10:36

    BackendUserAuthenticationTest.php:71

    Please let's duplicate this test (and rename it accordingly) instead of changing it. That way, we can have tests for both methods.
  15. Thomas Hohn commented on patch set 9 08/13/24, 10:57

    BackendUserAuthenticationTest.php:71 Reply

    Acknowledged
  16. Thomas Hohn uploaded patch set 10 V +1 08/13/24, 11:12

  17. Thomas Hohn commented on patch set 9 08/13/24, 11:12

    BackendUserAuthenticationTest.php:71 Reply

    Done
  18. core-ci voted on patch set 10 V +1 08/13/24, 11:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63303

  19. Christian Kuhn uploaded patch set 11 V +1 08/13/24, 11:32

  20. Christian Kuhn voted on patch set 11 CR +1 V +1 08/13/24, 11:32

  21. Andreas Kienast voted on patch set 11 CR +1 V +1 08/13/24, 11:34

  22. Christian Kuhn commented on patch set 11 CR +2 V +2 08/13/24, 11:34

    preparing backport.
  23. core-ci voted on patch set 11 V +1 08/13/24, 11:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63304

  24. Garvin Hicking commented on patch set 11 CR +1 08/13/24, 11:53

    I like how this evolved, thanks!
  25. Christian Kuhn merged patch set 12 08/13/24, 11:55