Review main Merged

96847[BUGFIX] Do not copy a folder into its own subfolder

Wolfgang Klinger CR +2 V +2 Normal +71 −0 updated 10/23/26, 07:57

Commit message

Copying a folder into one of its own subfolders created an endlessly
nested folder structure. The check that prevented this was dropped
when the conflict mode handling was added to copyFolder().

ResourceStorage::copyFolder() throws an InvalidTargetFolderException
again in this case, like moveFolder() does.

The file list now explains this case in its own message and log
entry, instead of reporting a name conflict in the target folder.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Oli Bartsch +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Oli Bartsch +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 3

Files 5

Review log 1214

  1. Wolfgang Klinger uploaded patch set 1 10/19/26, 06:37

  2. core-ci voted on patch set 1 V +1 10/19/26, 06:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111579

  3. Simon Schaufelberger commented on patch set 1 10/19/26, 14:54

    StorageRepositoryTest.php:560

    why don't you use ``` $this->expectException(InvalidTargetFolderException::class); $this->expectExceptionCode(1792390364); ```
  4. Wolfgang Klinger commented on patch set 1 10/19/26, 15:02

    StorageRepositoryTest.php:560 Reply

    Because there's an additional assert afterwards: assertDirectoryDoesNotExist. With expectException(), the test stops at the throw. Should I remove that in favor of using your suggested methods?
  5. Simon Schaufelberger commented on patch set 1 CR +1 V +1 10/19/26, 16:12

    StorageRepositoryTest.php:560 Reply

    ah ok. didn't know that. then leave it.
  6. Georg Ringer voted on patch set 1 CR +1 V +1 10/21/26, 19:52

  7. Oli Bartsch commented on patch set 1 CR -1 10/21/26, 20:35

    I don't see this as a priority bugfix..

    ResourceStorage.php:2269

    Suggest to move the check up to right after `assureFolderCopyPermissions()`, before `BeforeFolderCopiedEvent` is dispatched. Right now listeners get a Before event for a copy that never happens. With `CANCEL` and an existing `/foo/sub/foo`, the name-conflict exception 1422723059 also wins over the more precise message.

    ExtendedFileUtility.php:646

    `func_copy` picks the message by comparing `$e->getCode()` with the literal `1792390364`, which couples it to `ResourceStorage` through a number. Please either throw a subclass of `InvalidTargetFolderException` or pre-check with `isWithinFolder()` in `func_copy`, as the filelist controllers do. Also note that the old label key `...AlreadyWithinTheFolderToBeCopied` now carries the name-conflict text, so the keys are easy to mix up.

    ExtendedFileUtility.php:648

    The message uses `$targetFolderObject->getName()`, so copying `/foo/` onto itself reads 'cannot be copied into its own subfolder "foo"', and deep targets only show the leaf name. Suggest to use the target identifier like the other messages do.
  8. Wolfgang Klinger uploaded patch set 2 CR +1 V +1 10/22/26, 06:41

  9. core-ci voted on patch set 2 V +1 10/22/26, 06:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112064

  10. Oli Bartsch voted on patch set 2 CR +1 V +1 10/22/26, 20:07

  11. Oli Bartsch commented on patch set 2 10/22/26, 20:07

    Reply

    Done

    ResourceStorage.php:2269 Reply

    Done

    ExtendedFileUtility.php:646 Reply

    Done

    ExtendedFileUtility.php:648 Reply

    Done
  12. Simon Schaufelberger voted on patch set 2 CR +1 V +1 10/22/26, 20:57

  13. Georg Ringer voted on patch set 2 CR +2 V +2 10/23/26, 07:31

  14. Georg Ringer merged patch set 3 10/23/26, 07:57