8000 bug #23092 [Filesystem] added workaround in Filesystem::rename for PH… · symfony/filesystem@3722051 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3722051

Browse 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 symfony/symfony#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 ------- 3ccbc479da [Filesystem] added workaround in Filesystem::rename for PHP bug
2 parents b29c3eb + fc2b409 commit 3722051

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Filesystem.php

Lines 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