1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/13904] Improve test coverage and use constants instead of magic numbers

PHPBB3-13904
This commit is contained in:
Marc Alexander
2015-07-16 00:21:23 +02:00
parent a09c6d1fb7
commit 845233fc62
3 changed files with 61 additions and 11 deletions

View File

@@ -210,7 +210,7 @@ class upload
{
switch ($errorcode)
{
case 1:
case UPLOAD_ERR_INI_SIZE:
$max_filesize = @ini_get('upload_max_filesize');
$unit = 'MB';
@@ -223,29 +223,37 @@ class upload
}
$error = (empty($max_filesize)) ? $this->language->lang($this->error_prefix . 'PHP_SIZE_NA') : $this->language->lang($this->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, $this->language->lang($unit));
break;
break;
case 2:
case UPLOAD_ERR_FORM_SIZE:
$max_filesize = get_formatted_filesize($this->max_filesize, false);
$error = $this->language->lang($this->error_prefix . 'WRONG_FILESIZE', $max_filesize['value'], $max_filesize['unit']);
break;
break;
case 3:
case UPLOAD_ERR_PARTIAL:
$error = $this->language->lang($this->error_prefix . 'PARTIAL_UPLOAD');
break;
break;
case 4:
case UPLOAD_ERR_NO_FILE:
$error = $this->language->lang($this->error_prefix . 'NOT_UPLOADED');
break;
break;
case 6:
case UPLOAD_ERR_NO_TMP_DIR:
$error = 'Temporary folder could not be found. Please check your PHP installation.';
break;
break;
case UPLOAD_ERR_CANT_WRITE:
$error = 'Cant write to temporary folder.';
break;
case UPLOAD_ERR_EXTENSION:
$error = 'A PHP extension has stopped the file upload.';
break;
default:
$error = false;
break;
break;
}
return $error;