From e59852d336467e7269853724a28d80bc070bcbf6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 1 Jul 2007 17:41:16 +0000 Subject: - Rollback of patch #147723: delete API. Talked to Steven and Gabor and we unanimously agreed to rollback the deletion API. We all support the features this patch added, yet not its actual design and implementation. After some talk, we decided that it would be better for Drupal -- in the long term -- not to go with a solution that isn't 100%. We also recognize that in the short term, this patch would have been useful addition. So let's figure out how we can implement this properly in D7. --- modules/upload/upload.module | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'modules/upload') diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 43ae3f2f3..f8ddc5f86 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -575,44 +575,31 @@ function upload_delete($node) { } foreach ($files as $fid => $file) { - // Delete all file revision information associated with the node - drupal_delete_add_query('DELETE FROM {files} WHERE fid = %d', $fid); + // Delete all files associated with the node + db_query('DELETE FROM {files} WHERE fid = %d', $fid); + file_delete($file->filepath); } - // Delete all files associated with the node - drupal_delete_add_query('DELETE FROM {upload} WHERE nid = %d', $node->nid); - - // Register a callback to delete the files. - drupal_delete_add_callback(array('upload_delete_post' => array($files))); + // Delete all file revision information associated with the node + db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid); } function upload_delete_revision($node) { if (is_array($node->files)) { - $files = array(); foreach ($node->files as $file) { // Check if the file will be used after this revision is deleted $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $file->fid)); // if the file won't be used, delete it if ($count < 2) { - drupal_delete_add_query('DELETE FROM {files} WHERE fid = %d', $file->fid); - $files[$file->fid] = $file; + db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); + file_delete($file->filepath); } } } - // Delete the revision. - drupal_delete_add_query('DELETE FROM {upload} WHERE vid = %d', $node->vid); - - // Register a callback to delete the files. - drupal_delete_add_callback(array('upload_delete_post' => array($files))); -} - -function upload_delete_post($files) { - foreach ($files as $file) { - // Delete all files associated with the node or revision. - file_delete($file->filepath); - } + // delete the revision + db_query('DELETE FROM {upload} WHERE vid = %d', $node->vid); } function _upload_form($node) { -- cgit v1.2.3