summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorAndreas <andreas@immerda.ch>2011-12-02 16:53:45 -0300
committerAndreas <andreas@immerda.ch>2011-12-02 16:53:45 -0300
commit240ae87c0d27cafd0fd35f036af6f13a4158983f (patch)
tree4a2386eacd50fab9d431a2f3793dd408e610b1d2 /includes
parent462d44bf172e7c411235e1775dd8c61e6dcb024f (diff)
issue with file: http://drupal.org/node/1240256#comment-4985614HEADmaster
Diffstat (limited to 'includes')
-rw-r--r--includes/file.inc11
1 files changed, 9 insertions, 2 deletions
diff --git a/includes/file.inc b/includes/file.inc
index 40e8349..5de4a98 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -828,6 +828,9 @@ function file_valid_uri($uri) {
* is reported.
* - If file already exists in $destination either the call will error out,
* replace the file or rename the file based on the $replace parameter.
+ * - Provides a fallback using realpaths if the move fails using stream
+ * wrappers. This can occur because PHP's copy() function does not properly
+ * support streams if safe_mode or open_basedir are enabled.
*
* @param $source
* A string specifying the filepath or URI of the source file.
@@ -907,8 +910,12 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
file_ensure_htaccess();
// Perform the copy operation.
if (!@copy($source, $destination)) {
- watchdog('file', 'The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination), WATCHDOG_ERROR);
- return FALSE;
+ // If the copy failed and realpaths exist, retry the operation using them
+ // instead.
+ if ($real_source === FALSE || $real_destination === FALSE || !@copy($real_source, $real_destination)) {
+ watchdog('file', 'The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination), WATCHDOG_ERROR);
+ return FALSE;
+ }
}
// Set the permissions on the new file.