Commit f2c05c63 authored by webchick's avatar webchick

#197266 by ufku, lilou, Dave Reid, and c960657: Avoid unnecessary query if...

#197266 by ufku, lilou, Dave Reid, and c960657: Avoid unnecessary query if there is no user limit on uploaded files.
parent 804b313a
...@@ -733,7 +733,7 @@ function file_validate_extensions($file, $extensions) { ...@@ -733,7 +733,7 @@ function file_validate_extensions($file, $extensions) {
* @param $file_limit * @param $file_limit
* An integer specifying the maximum file size in bytes. Zero indicates that * An integer specifying the maximum file size in bytes. Zero indicates that
* no limit should be enforced. * no limit should be enforced.
* @param $$user_limit * @param $user_limit
* An integer specifying the maximum number of bytes the user is allowed. * An integer specifying the maximum number of bytes the user is allowed.
* Zero indicates that no limit should be enforced. * Zero indicates that no limit should be enforced.
* @return * @return
...@@ -751,8 +751,7 @@ function file_validate_size($file, $file_limit = 0, $user_limit = 0) { ...@@ -751,8 +751,7 @@ function file_validate_size($file, $file_limit = 0, $user_limit = 0) {
$errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit))); $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit)));
} }
$total_size = file_space_used($user->uid) + $file->filesize; if ($user_limit && (file_space_used($user->uid) + $file->filesize) > $user_limit) {
if ($user_limit && $total_size > $user_limit) {
$errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit))); $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit)));
} }
} }
......
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