diff --git a/core/includes/file.inc b/core/includes/file.inc index babf465..32c2820 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -1236,7 +1236,7 @@ function file_create_filename($basename, $directory) { * @see hook_file_predelete() * @see hook_file_delete() */ -function file_delete(stdClass $file, $force = FALSE) { +function file_delete(stdClass $file) { if (!file_valid_uri($file->uri)) { if (($realpath = drupal_realpath($file->uri)) !== FALSE) { watchdog('file', 'File %file (%realpath) could not be deleted because it is not a valid URI. This may be caused by improper use of file_delete() or a missing stream wrapper.', array('%file' => $file->uri, '%realpath' => $realpath)); @@ -1248,12 +1248,6 @@ function file_delete(stdClass $file, $force = FALSE) { return FALSE; } - // If any module still has a usage entry in the file_usage table, the file - // will not be deleted, but file_delete() will return a populated array - // that tests as TRUE. - if (!$force && ($references = file_usage_list($file))) { - return $references; - } // Let other modules clean up any references to the file prior to deletion. module_invoke_all('file_predelete', $file); diff --git a/core/modules/file/tests/file.test b/core/modules/file/tests/file.test index a08218d..1bc3e75 100644 --- a/core/modules/file/tests/file.test +++ b/core/modules/file/tests/file.test @@ -697,9 +697,6 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { // Delete the second revision and check that the file is kept (since it is // still being used by the third revision). $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting second revision, since it is being used by the third revision.')); // Attach the second file to a user. $user = $this->drupalCreateUser(); @@ -711,9 +708,7 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { // Delete the third revision and check that the file is not deleted yet. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', array(), t('Delete')); $this->assertFileExists($node_file_r3, t('Second file is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting third revision, since it is being used by the user.')); - + // Delete the user and check that the file is also deleted. user_delete($user->uid); // TODO: This seems like a bug in File API. Clearing the stat cache should diff --git a/core/modules/simpletest/tests/file.test b/core/modules/simpletest/tests/file.test index 7496902..008e198 100644 --- a/core/modules/simpletest/tests/file.test +++ b/core/modules/simpletest/tests/file.test @@ -1552,33 +1552,6 @@ class FileDeleteTest extends FileHookTestCase { $this->assertFalse(file_load($file->fid), t('File was removed from the database.')); } - /** - * Tries deleting a file that is in use. - */ - function testInUse() { - $file = $this->createFile(); - file_usage_add($file, 'testing', 'test', 1); - file_usage_add($file, 'testing', 'test', 1); - - file_usage_delete($file, 'testing', 'test', 1); - file_delete($file); - $usage = file_usage_list($file); - $this->assertEqual($usage['testing']['test'], array(1 => 1), t('Test file is still in use.')); - $this->assertTrue(file_exists($file->uri), t('File still exists on the disk.')); - $this->assertTrue(file_load($file->fid), t('File still exists in the database.')); - - // Clear out the call to hook_file_load(). - file_test_reset(); - - file_usage_delete($file, 'testing', 'test', 1); - file_delete($file); - $usage = file_usage_list($file); - $this->assertFileHooksCalled(array('delete')); - $this->assertTrue(empty($usage), t('File usage data was removed.')); - $this->assertFalse(file_exists($file->uri), t('File has been deleted after its last usage was removed.')); - $this->assertFalse(file_load($file->fid), t('File was removed from the database.')); - } -} /**