From ad9c37ffd474c33d8a3ec22104985a310a20d958 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 25 Mar 2010 12:19:34 +0000 Subject: [PATCH] - Patch #747464 by andypost: fixed wrong usage of hook_file_references(). --- modules/system/system.api.php | 6 +++--- modules/user/user.module | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/system/system.api.php b/modules/system/system.api.php index c43bcf05efc..6ff9be0ec17 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -1734,10 +1734,10 @@ function hook_file_move($file, $source) { */ function hook_file_references($file) { // 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) { + $file_used = (bool) db_query_range('SELECT 1 FROM {user} WHERE pictire = :fid', 0, 1, array(':fid' => $file->fid))->fetchField(); + if ($file_used) { // Return the name of the module and how many references it has to the file. - return array('user' => $count); + return array('user' => 1); } } diff --git a/modules/user/user.module b/modules/user/user.module index 7057a0b9473..5f6264a3f23 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -773,10 +773,11 @@ function user_file_download($uri) { */ function user_file_references($file) { // Determine if the file is used by this module. - $count = (int) db_query('SELECT COUNT(1) FROM {users} WHERE picture = :fid', array(':fid' => $file->fid))->fetchField(); - if ($count) { + $file_used = (bool) db_query_range('SELECT 1 FROM {users} WHERE picture = :fid', 0, 1, array(':fid' => $file->fid))->fetchField(); + if ($file_used) { // Return the name of the module and how many references it has to the file. - return array('user' => $count); + // If file is still used then 1 is enough to indicate this. + return array('user' => 1); } }