Permalink
Browse files

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
  • Loading branch information...
2 parents d6cda54 + 4671c92 commit 1ad2bdf713147bb296c067f3381f7e9d80cd06a2 @fabpot fabpot committed May 1, 2013
Showing with 13 additions and 1 deletion.
  1. +13 −1 Filesystem.php
View
@@ -35,6 +35,10 @@ class Filesystem
*/
public function copy($originFile, $targetFile, $override = false)
{
+ if (!is_file($originFile)) {
+ throw new IOException(sprintf('Failed to copy %s because file not exists', $originFile));
+ }
+
$this->mkdir(dirname($targetFile));
if (!$override && is_file($targetFile)) {
@@ -44,7 +48,15 @@ public function copy($originFile, $targetFile, $override = false)
}
if ($doCopy) {
- if (true !== @copy($originFile, $targetFile)) {
+ // https://bugs.php.net/bug.php?id=64634
+ $source = fopen($originFile, 'r');
+ $target = fopen($targetFile, 'w+');
+ stream_copy_to_stream($source, $target);
+ fclose($source);
+ fclose($target);
+ unset($source, $target);
+
+ if (!is_file($targetFile)) {
throw new IOException(sprintf('Failed to copy %s to %s', $originFile, $targetFile));
}
}

0 comments on commit 1ad2bdf

Please sign in to comment.