Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d44f143

Browse filesBrowse files
committed
bug #23092 [Filesystem] added workaround in Filesystem::rename for PHP bug (VolCh)
This PR was squashed before being merged into the 2.7 branch (closes #23092). Discussion ---------- [Filesystem] added workaround in Filesystem::rename for PHP bug [Filesystem] added workaround in Filesystem::rename for https://bugs.php.net/bug.php?id=54097 Standard PHP rename() of dirs across devices/mounted filesystems produces confusing copy error & throws IOException in Filesystem::rename. I got it during console cache:clear in the Docker environment. This PR possible fixes #19851 and other environment related issues. Workaround is on \rename() fails try to Filesystem::mirror & Filesystem::remove if $origin is directory | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 3ccbc47 [Filesystem] added workaround in Filesystem::rename for PHP bug
2 parents f0abe11 + 3ccbc47 commit d44f143
Copy full SHA for d44f143

File tree

1 file changed

+7
-0
lines changed
Filter options

1 file changed

+7
-0
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ public function rename($origin, $target, $overwrite = false)
276276
}
277277

278278
if (true !== @rename($origin, $target)) {
279+
if (is_dir($origin)) {
280+
// See https://bugs.php.net/bug.php?id=54097 & http://php.net/manual/en/function.rename.php#113943
281+
$this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
282+
$this->remove($origin);
283+
284+
return;
285+
}
279286
throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
280287
}
281288
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.