From 0a8e485e347a5a065c53f48fe3615cbd043d4e4e Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Sat, 18 Jun 2011 01:22:13 -0400
Subject: [PATCH] Issue #1192458 by pillarsdotnet: Make file_move() code match docs.

---
 includes/file.inc |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/includes/file.inc b/includes/file.inc
index 4750ff481fe297ea9581782b1f71ba9207d8043c..cb1a2c617f4cc7bb140b2b0ece25ebff406268b3 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -987,6 +987,10 @@ function file_destination($destination, $replace) {
  * @see hook_file_move()
  */
 function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
+  // Build a destination URI if necessary.
+  if (!isset($destination)) {
+    $destination = file_build_uri(basename($source->uri));
+  }
   if (!file_valid_uri($destination)) {
     watchdog('file', 'File %file (%realpath) could not be moved, because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->uri, '%realpath' => drupal_realpath($source->uri), '%destination' => $destination));
     drupal_set_message(t('The specified file %file could not be moved, because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
-- 
1.7.4.1

