diff options
-rw-r--r-- | modules/system/system.api.php | 8 | ||||
-rw-r--r-- | modules/user/user.module | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 936ca9079..bd42f2292 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -1724,11 +1724,11 @@ function hook_file_move($file, $source) { * @see upload_file_references() */ function hook_file_references($file) { - // If upload.module is still using a file, do not let other modules delete it. - $file_used = (bool) db_query_range('SELECT 1 FROM {upload} WHERE fid = :fid', 0, 1, array(':fid' => $file->fid))->fetchField(); - if ($file_used) { + // If user.module is still using a file, do not let other modules delete it. + $count = (int) db_query('SELECT COUNT(picture) FROM {users} WHERE picture = :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); + return array('user' => $count); } } diff --git a/modules/user/user.module b/modules/user/user.module index b62efd70d..2ec522113 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -775,8 +775,8 @@ function user_file_download($uri) { */ function user_file_references($file) { // Determine if the file is used by this module. - $file_used = (bool) db_query_range('SELECT 1 FROM {users} WHERE picture = :fid', 0, 1, array(':fid' => $file->fid))->fetchField(); - if ($file_used) { + $count = (int) db_query('SELECT COUNT(1) FROM {users} WHERE picture = :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('user' => $count); } |