Problem/Motivation
$destination will always be FALSE at the time FileExistsException is thrown in FileSystem::prepareDestination().
https://git.drupalcode.org/project/drupal/-/blob/902684ebd0252ccabf4dbe9...
Steps to reproduce
$file_system = \Drupal::service('file_system');
file_put_contents('public://test.txt', 'test');
mkdir('public://test2.txt');
$file_system->copy('public://test.txt', 'public://test2.txt', 2);Proposed resolution
Retain the original destination for output in exception.
Adjust tests to ensure path is included in validation.
Alternative:
Remove path from message
Remaining tasks
User interface changes
Exception will now include a PATH.
Introduced terminology
None
API changes
None Expected
Data model changes
None Expected
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3615576.patch | 1.87 KB | shank115 |
Issue fork drupal-3615576
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
shank115 commentedCheck if the attached patch fixes the issue.
Comment #5
kieran.cottI have not been able to reproduce this issue using the steps in the issue summary since copying into an empty directory succeeds. However, the issue can be reproduced with:
@shank115's patch fixes the issue for me by by retaining
$destinationbeforegetDestinationFilename()replaces it withFALSE, and the associated test checks the corrected path.I've implemented the patch as an MR for review.
Comment #6
smustgrave commentedThanks @kieran.cott MR looks fine but wanted to note this was tagged novice and looking at your post history believe you can avoid this now! Congrats! No problem here just noting for future tickets.
Comment #7
kieran.cottThanks @smustgrave, will avoid Novice issues going forward. :)
Comment #8
smustgrave commentedLet me amend my previous statement if a novice issue has sat for 2-3 weeks then it's fair game.
Comment #11
godotislateCommitted and pushed cfcf382 to main and 6b67f19 to 11.x. Thanks!