? .cache
? .cvsignore
? .git
? .project
? .settings
? empty
? file_329226_0.patch
? file_create_url-14.patch
? more
? test
? upload-js-fix_1.diff
? uploadbugtest.tar_.gz
? modules/file
? sites/all/modules
? sites/default/files
? sites/default/settings.php
? sites/default/test
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.140
diff -u -p -r1.140 file.inc
--- includes/file.inc	19 Oct 2008 20:18:58 -0000	1.140
+++ includes/file.inc	6 Nov 2008 01:55:37 -0000
@@ -708,7 +708,7 @@ function file_delete($file, $force = FAL
   // If any module returns a value from the reference hook, the file will not
   // be deleted from Drupal, but file_delete will return a populated array that
   // tests as TRUE.
-  if (!$force && ($references = module_invoke_all('file_references', $file))) {
+  if (!$force && ($references = file_usage($file))) {
     return $references;
   }
 
@@ -758,6 +758,27 @@ function file_unmanaged_delete($path) {
 }
 
 /**
+ * Determine if and where a file is used.
+ *
+ * @param $file
+ *   A file object.
+ * @return
+ *   An array of paths to instances where the file is used.
+ */
+function file_usage($file) {
+  $file = (object)$file;
+  $return = array();
+  foreach (module_implements('file_references') as $name) {
+    $function = $name . '_' . $hook;
+    $result = $function($file, $mode);
+    if (!empty($result)) {
+      $return[$name] = $result;
+    }
+  }
+  return $return;
+}
+
+/**
  * Determine total disk space used by a single user or the whole filesystem.
  *
  * @param $uid
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.214
diff -u -p -r1.214 upload.module
--- modules/upload/upload.module	2 Nov 2008 20:24:46 -0000	1.214
+++ modules/upload/upload.module	6 Nov 2008 01:55:37 -0000
@@ -279,13 +279,15 @@ function upload_file_load(&$file) {
 /**
  * Implementation of hook_file_references().
  */
-function upload_file_references(&$file) {
-  // If upload.module is still using a file, do not let other modules delete it.
-  $count = db_query('SELECT COUNT(*) FROM {upload} WHERE fid = :fid', array(':fid' => $file->fid))->fetchField();
-  if ($count) {
-    // Return the name of the module and how many references it has to the file.
-    return array('upload' => $count);
+function upload_file_references($file) {
+  // If upload.module is still using a file return an array of links where
+  // it's used.
+  $usage = array();
+  $result = db_query('SELECT DISTINCT nid, title FROM {upload} WHERE fid = :fid', array(':fid' => $file->fid));
+  foreach ($result as $node) {
+    $usage[] = array($node->title, 'node/' . $node->nid, array());
   }
+  return $usage;
 }
 
 /**
