Review main Merged

67442[BUGFIX] Show proper error when a folder already exists on copy action

Richard Haeser CR +2 V +2 Normal +108 −16 updated 03/12/21, 10:45

Commit message

When you copy a folder to another (or the same) parent folder that
already contains a folder or file with the same name, a proper error
message will be shown to the user.

Review

  • Code review CR +2 Done
    • Richard Haeser +2
    • Guido Schmechel +1
    • Markus Klein +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Richard Haeser +2
    • Guido Schmechel +1
    • Markus Klein +1
    • Christian Kuhn +1
    • TYPO3com +1 CI
    • core-ci +1 CI

Issues 1

Files 4

Review log 4051

Show 2026 earlier messages
  1. Richard Haeser uploaded patch set 1 01/13/21, 08:45

  2. Richard Haeser uploaded patch set 2 01/13/21, 08:51

  3. Mathias Brodala commented on patch set 2 01/13/21, 08:56

    ResourceStorage.php:2270

    Since the folder could have a slightly different name due to sanitation we should mention the original folder name too.
  4. TYPO3com voted on patch set 1 V -1 01/13/21, 08:57 Completed build in 11m 51s on Wed, 13 Jan, 08:57 AM Test Summary: 32575 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8843

  5. TYPO3com voted on patch set 2 V -1 01/13/21, 09:02 Completed build in 10m 56s on Wed, 13 Jan, 09:02 AM Test Summary: 1 of 32816 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8844

  6. Richard Haeser commented on patch set 2 01/13/21, 10:48

    ResourceStorage.php:2270 Reply

    I don't think we should do this on this location. We can alter the message that is shown to the user, but I'm not sure if this will bring a lot of extra information and might cause really long error messages. What would you propose regarding the message?
  7. Mathias Brodala commented on patch set 2 01/13/21, 10:54

    ResourceStorage.php:2270 Reply

    I just want to avoid confusion for the user due to an error message mentioning a folder name which may not be the one he tried to create. The message should at least hint at the implicit sanitation: > Folder "<folder>" (name possibly sanitized) already exists.
  8. Richard Haeser commented on patch set 2 01/13/21, 10:58

    ResourceStorage.php:2270 Reply

    I have an idea and will push a new patchset, but not for this throwing error, but for the text that is shown to the user.
  9. TYPO3com voted on patch set 2 V +1 01/13/21, 10:58 Completed build in 09m 30s on Wed, 13 Jan, 10:58 AM Test Summary: 32575 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8845

  10. Richard Haeser uploaded patch set 3 01/13/21, 23:52

  11. Richard Haeser commented on patch set 2 01/13/21, 23:53

    ResourceStorage.php:2270 Reply

    Fixed. Also altered the error message a bit to have a bit more "friendly" message towards the user.
  12. Mathias Brodala commented on patch set 3 CR +1 01/14/21, 07:33

    This sounds good know, thanks for caring!
  13. Markus Gerdes commented on patch set 3 CR +1 01/14/21, 07:50

    The adjustments look good to me. Thx
  14. Oliver Hader commented on patch set 3 CR -1 01/14/21, 08:49

    ResourceStorage.php:2258

    `$conflictMode` is not considered at all this this method When adjusting implementation for the scope of copying, this now should be considered - the current implementation would be a hard-coded `CANCEL` handling. In `ExtendedFileUtility::func_copy` conflict mode either can be `RENAME` or `CANCEL`. Handling `RENAME` seems to be missing in current `ResourceStorage::copyFolder` implementation.
  15. Oli Bartsch commented on patch set 3 01/14/21, 09:07

    ExistingTargetFolderNameException.php:20

    Could we just use the already existing ExistingTargetFolderException - or what is the difference? Is it only about adding a separate flash message?

    ResourceStorage.php:2276

    Curious, just from reading, why is this not already handled here?

    fileMessages.xlf:157

    Suggest to use "A file or folder with the name ..." here, when also checking for files.
  16. Richard Haeser commented on patch set 3 01/17/21, 08:11

    ResourceStorage.php:2258 Reply

    You are right although that will not fix the bug. The default conflictMode is rename, but as far as I see the conflictMode is set to cancel. And although the rename part is missing, the bug is actually the cancel part. Cancel with an exception is not quite user friendly. In https://forge.typo3.org/issues/64363 I will work on some UI stuff to give an editor the option what to do. Do you agree to fix this bug first with the cancel conflictmode and do the correct conflictmode handling in that issue?

    ResourceStorage.php:2276 Reply

    Well you are right. As far as I can see, I think this method was used to check this. But the problem is that this method is only checking if it is part of the directory so (if handled correctly. IMO the two params should be the other way around) this would cause copying a folder from /user_upload/some_dir/folder_to_copy to target directory /user_upload to fail as /user_upload/some_dir/folder_to_copy is within /user_upload. So I think this check does not make much sense. But maybe I'm wrong.
  17. Richard Haeser uploaded patch set 4 01/17/21, 11:40

  18. Richard Haeser commented on patch set 4 CR -1 01/17/21, 11:42

    On it

    ResourceStorage.php:2258 Reply

    Ok, I disagree with myself now. Working on it.
  19. TYPO3com voted on patch set 4 V -1 01/17/21, 11:51 Completed build in 10m 13s on Sun, 17 Jan, 11:51 AM Test Summary: 32589 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8896

  20. Richard Haeser uploaded patch set 5 01/19/21, 15:59

  21. Richard Haeser voted on patch set 5 CR -1 01/20/21, 13:10

  22. TYPO3com voted on patch set 5 V -1 01/20/21, 13:17 Completed build in 08m 38s on Wed, 20 Jan, 01:17 PM Test Summary: 32607 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8935

  23. Richard Haeser uploaded patch set 6 01/20/21, 13:22

  24. TYPO3com voted on patch set 6 V +1 01/20/21, 13:31 Completed build in 08m 46s on Wed, 20 Jan, 01:31 PM Test Summary: 32607 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8936

  25. Richard Haeser uploaded patch set 7 01/20/21, 14:14

  26. Richard Haeser commented on patch set 7 01/20/21, 14:15

    Currently the conflictmode is not used for the use case of the bugreport. This will be fixed in a new feature patch. However, you can use the public methods which do have the conflictmode parameter. I added a couple of functional tests to test the behaviour.
  1. TYPO3com voted on patch set 7 V +1 01/20/21, 14:23 Completed build in 08m 35s on Wed, 20 Jan, 02:23 PM Test Summary: 32607 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8937

  2. Richard Haeser commented on patch set 7 01/20/21, 14:34

    ExistingTargetFolderNameException.php:20 Reply

    Done

    ResourceStorage.php:2258 Reply

    Done

    ResourceStorage.php:2276 Reply

    Done

    fileMessages.xlf:157 Reply

    Done
  3. Markus Gerdes voted on patch set 7 CR +1 02/01/21, 08:44

  4. Martin Kutschker voted on patch set 7 V +1 CR +1 02/14/21, 17:17

  5. Guido Schmechel commented on patch set 7 02/21/21, 12:00

    Works as expected. I've just tested with the root folder "fileadmin". Given flash message was: "Cannot copy folder "ordner2" into target folder "", because the target folder is already within the folder to be copied!" Should we catch the empty root folder to have a clearer error message?
  6. Martin Kutschker commented on patch set 7 V 0 CR 0 02/21/21, 17:27

    Reply

    Yes. Doesn't make much sense to improve the messages and have an odd man standing out :)
  7. Martin Kutschker commented on patch set 7 02/21/21, 19:34

    Reply

    Stupid me. The TYPO3 code has 3 (!) times the same text. The original patch only changes the internal message, but not the XLIFF file.
  8. Martin Kutschker uploaded patch set 8 02/21/21, 19:34

  9. Martin Kutschker voted on patch set 8 V +1 CR +1 02/21/21, 19:35

  10. TYPO3com voted on patch set 8 V +1 02/21/21, 19:44 Completed build in 09m 09s on Sun, 21 Feb, 07:44 PM Test Summary: 32696 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9649

  11. core-ci voted on patch set 8 V +1 02/21/21, 19:44 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/875

  12. Guido Schmechel commented on patch set 8 V -1 03/07/21, 10:29

    There is still the problem that the name of the root folder, e.g. fileadmin, is not resolved in the flasd message.
  13. Richard Haeser uploaded patch set 9 03/08/21, 13:11

  14. Richard Haeser commented on patch set 9 03/08/21, 13:11

    Reply

    Fixed
  15. TYPO3com voted on patch set 9 V +1 03/08/21, 13:18 Completed build in 07m 04s on Mon, 8 Mar, 01:18 PM Test Summary: 32757 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9924

  16. core-ci voted on patch set 9 V +1 03/08/21, 13:21 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1269

  17. Guido Schmechel commented on patch set 9 03/10/21, 18:50

    Instead of an empty string i get now "/", because this is the identifier of a storage root. Maybe we can catch this case? if ($targetFolderObject->getIdentifier() === '/') { // Custom Storage Name e.g. ("My cool fileadmin") echo $targetFolderObject->getStorage()->getName(); // Folder Name. Could be "fileadmin/" or also an absolute path like "/var/www/html/fileadmin" echo $targetFolderObject->getStorage()->getConfiguration()['basePath']; } I am undecided what is good for the user. Maybe it's just as well for now? Basically the patch works :-)
  18. Richard Haeser commented on patch set 9 03/10/21, 18:59

    Reply

    Well I think most people understand / as the root of the folder. Besides that, this is used in all other situations as well. So if we would like to change this, we should do that everywhere and IMHO this is out of scope for this bugfix.
  19. Guido Schmechel commented on patch set 9 V +1 CR +1 03/10/21, 19:16

    Reply

    I am fine with it ;-)
  20. Richard Haeser commented on patch set 9 03/10/21, 19:18

    Reply

    Don't get me wrong. I think we should investigate if this kind of messages is clear enough for users. It is just that this bugfix is making sure people don't get fatal errors.
  21. Guido Schmechel commented on patch set 9 03/10/21, 19:27

    Reply

    All good. You are right about the bugfix context and the actual problem is solved. So: Go for it! ;-)
  22. Markus Klein voted on patch set 9 V +1 CR +1 03/12/21, 08:48

  23. Christian Kuhn voted on patch set 9 V +1 CR +1 03/12/21, 10:43

  24. Richard Haeser voted on patch set 9 V +2 CR +2 03/12/21, 10:45

  25. Richard Haeser merged patch set 10 03/12/21, 10:45