Commit 1b927f54 authored by Dries's avatar Dries

Issue #1468210 by marthinal, quicksketch: remove special ->uid == 1 check in...

Issue #1468210 by marthinal, quicksketch: remove special ->uid == 1 check in filefield_validate_size().
parent 584e709d
......@@ -530,16 +530,13 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) {
$errors = array();
// Bypass validation for uid = 1.
if ($user->uid != 1) {
if ($file_limit && $file->filesize > $file_limit) {
if ($file_limit && $file->filesize > $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)));
}
}
// Save a query by only calling file_space_used() when a limit is provided.
if ($user_limit && (file_space_used($user->uid) + $file->filesize) > $user_limit) {
if ($user_limit && (file_space_used($user->uid) + $file->filesize) > $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)));
}
}
return $errors;
}
......
......@@ -133,13 +133,6 @@ function testFileValidateSize() {
$original_user = $user;
drupal_save_session(FALSE);
// Run these test as uid = 1.
$user = user_load(1);
$file = entity_create('file', array('filesize' => 999999));
$errors = file_validate_size($file, 1, 1);
$this->assertEqual(count($errors), 0, t('No size limits enforced on uid=1.'), 'File');
// Run these tests as a regular user.
$user = $this->drupalCreateUser();
......
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