diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/file.inc | 6 |
1 files changed, 2 insertions, 4 deletions
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(); } } |