From 7874654909fcbe0c3dad8f5533a2db19b8dd1c94 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 28 Sep 2010 02:34:42 +0000 Subject: - Patch #924554 by quicksketch, paul.lovvik: an exception is being thrown in the file_usage_delete() function if the corresponding file is not in the 'file_usage()' table. --- includes/file.inc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/file.inc b/includes/file.inc index 1d4343da0..769493a61 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -661,7 +661,7 @@ function file_usage_delete(stdClass $file, $module, $type = NULL, $id = NULL, $c $result = $query->execute(); // If the row has more than the specified count decrement it by that number. - if (!$result) { + if (!$result && $count > 0) { $query = db_update('file_usage') ->condition('module', $module) ->condition('fid', $file->fid); @@ -670,9 +670,7 @@ function file_usage_delete(stdClass $file, $module, $type = NULL, $id = NULL, $c ->condition('type', $type) ->condition('id', $id); } - if ($count) { - $query->expression('count', 'count - :count', array(':count' => $count)); - } + $query->expression('count', 'count - :count', array(':count' => $count)); $query->execute(); } } -- cgit v1.2.3