Commit 9b4013fd authored by Dries's avatar Dries

- Patch #504422 by catch, drewish: file_load_multiple() missing a sanity check.

parent 12893d0b
......@@ -494,6 +494,11 @@ function file_check_location($source, $directory = '') {
* @see file_load()
*/
function file_load_multiple($fids = array(), $conditions = array()) {
// If they don't provide any criteria return nothing rather than all files.
if (!$fids && !$conditions) {
return array();
}
$query = db_select('files', 'f')->fields('f');
// If the $fids array is populated, add those to the query.
......
......@@ -598,6 +598,9 @@ class FileSaveUploadTest extends FileHookTestCase {
$files = file_load_multiple(array($file1->fid, $file2->fid));
$this->assertTrue(isset($files[$file1->fid]), t('File was loaded successfully'));
$this->assertTrue(isset($files[$file2->fid]), t('File was loaded successfully'));
// Check that file_load_multiple() with no arguments returns FALSE.
$this->assertFalse(file_load_multiple(), t('No files were loaded.'));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment