#30520 follow-up by Dave Reid: Fix error message about upload when not uploading a file (with tests, so we don't break it again).
parent
09ed948a25
commit
cb07c9992b
|
@ -845,8 +845,8 @@ function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
|
|||
* 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, $validators = array(), $destination = FALSE,
|
|||
}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -599,6 +599,14 @@ class FileSaveUploadTest extends FileHookTestCase {
|
|||
// 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 FileTestCase {
|
|||
$this->assertIdentical($unmunged_name, $this->name, t('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ function _file_test_form_submit(&$form, &$form_state) {
|
|||
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');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue