Skip to content

Commit 1ad2bdf

Browse files
committed
Merge branch '2.2'
* 2.2: [Swiftmailer] bumped allowed versions remove validation related headers when needed use while loop for iterating [Filesystem] copy() is not working when open_basedir is set
2 parents d6cda54 + 4671c92 commit 1ad2bdf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Filesystem.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class Filesystem
3535
*/
3636
public function copy($originFile, $targetFile, $override = false)
3737
{
38+
if (!is_file($originFile)) {
39+
throw new IOException(sprintf('Failed to copy %s because file not exists', $originFile));
40+
}
41+
3842
$this->mkdir(dirname($targetFile));
3943

4044
if (!$override && is_file($targetFile)) {
@@ -44,7 +48,15 @@ public function copy($originFile, $targetFile, $override = false)
4448
}
4549

4650
if ($doCopy) {
47-
if (true !== @copy($originFile, $targetFile)) {
51+
// https://bugs.php.net/bug.php?id=64634
52+
$source = fopen($originFile, 'r');
53+
$target = fopen($targetFile, 'w+');
54+
stream_copy_to_stream($source, $target);
55+
fclose($source);
56+
fclose($target);
57+
unset($source, $target);
58+
59+
if (!is_file($targetFile)) {
4860
throw new IOException(sprintf('Failed to copy %s to %s', $originFile, $targetFile));
4961
}
5062
}

0 commit comments

Comments
 (0)