Commit ad9c37ff authored by Dries's avatar Dries

- Patch #747464 by andypost: fixed wrong usage of hook_file_references().

parent cca8e7e5
......@@ -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);
}
}
......
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment