Skip to content

Commit 3ccbc47

Browse files
VolChfabpot
authored andcommitted
[Filesystem] added workaround in Filesystem::rename for PHP bug
1 parent 62cbfdd commit 3ccbc47

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Symfony/Component/Filesystem/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)