? modules/simpletest/tests/343502.test
? modules/simpletest/tests/343502.test.txt
? sites/all/modules
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.152
diff -u -p -r1.152 file.inc
--- includes/file.inc	10 Jan 2009 06:09:54 -0000	1.152
+++ includes/file.inc	20 Jan 2009 02:36:36 -0000
@@ -845,8 +845,8 @@ function file_space_used($uid = NULL, $s
  *   destination directory should overwritten. A false value will generate a
  *   new, unique filename in the destination directory.
  * @return
- *   An object containing the file information, or FALSE in the event of an
- *   error.
+ *   An object containing the file information if the upload succeeded, FALSE
+ *   in the event of an error, or NULL if no file was uploaded.
  */
 function file_save_upload($source, $validators = array(), $destination = FALSE, $replace = FILE_EXISTS_RENAME) {
   global $user;
@@ -859,8 +859,8 @@ function file_save_upload($source, $vali
   }
 
   // Make sure there's an upload to process.
-  if (!isset($_FILES['files']['name'][$source])) {
-    return FALSE;
+  if (empty($_FILES['files']['name'][$source])) {
+    return NULL;
   }
 
   // Check for file upload errors and return FALSE if a lower level system
Index: modules/simpletest/tests/file.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/file.test,v
retrieving revision 1.20
diff -u -p -r1.20 file.test
--- modules/simpletest/tests/file.test	10 Jan 2009 06:09:54 -0000	1.20
+++ modules/simpletest/tests/file.test	20 Jan 2009 02:36:39 -0000
@@ -599,6 +599,14 @@ class FileSaveUploadTest extends FileHoo
     // Check that the no hooks were called while failing.
     $this->assertFileHooksCalled(array());
   }
+
+  /**
+   * Test for no failures when not uploading a file.
+   */
+  function testNoUpload() {
+    $this->drupalPost('file-test/upload', array(), t('Submit'));
+    $this->assertNoRaw(t('Epic upload FAIL!'), t('Failure message not found.'));
+  }
 }
 
 /**
@@ -1765,4 +1773,3 @@ class FileNameMungingTest extends FileTe
     $this->assertIdentical($unmunged_name, $this->name, t('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name)));
   }
 }
-
Index: modules/simpletest/tests/file_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/file_test.module,v
retrieving revision 1.7
diff -u -p -r1.7 file_test.module
--- modules/simpletest/tests/file_test.module	10 Jan 2009 06:09:54 -0000	1.7
+++ modules/simpletest/tests/file_test.module	20 Jan 2009 02:36:39 -0000
@@ -61,7 +61,7 @@ function _file_test_form_submit(&$form, 
     drupal_set_message(t('File @filepath was uploaded.', array('@filepath' => $file->filepath)));
     drupal_set_message(t('You WIN!'));
   }
-  else {
+  elseif ($file === FALSE) {
     drupal_set_message(t('Epic upload FAIL!'), 'error');
   }
 }
