mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Upload_Validator failed to fetch max size from PHP ini values (fixes #6999)
This commit is contained in:
parent
058ba813e6
commit
4ad2cae864
@ -396,7 +396,7 @@ class Upload_Validator {
|
||||
if (empty($this->allowedMaxFileSize)) {
|
||||
// Set default max file sizes if there isn't
|
||||
$fileSize = Config::inst()->get('Upload_Validator', 'default_max_file_size');
|
||||
if (isset($fileSize)) {
|
||||
if (!empty($fileSize)) {
|
||||
$this->setAllowedMaxFileSize($fileSize);
|
||||
} else {
|
||||
// When no default is present, use maximum set by PHP
|
||||
|
@ -134,6 +134,12 @@ class UploadTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testGetAllowedMaxFileSize() {
|
||||
// Check the max file size defaults to PHP settings
|
||||
$maxPhpSize = min(File::ini2bytes(ini_get('upload_max_filesize')), File::ini2bytes(ini_get('post_max_size')));
|
||||
$v = new UploadTest_Validator();
|
||||
$retrievedSize = $v->getAllowedMaxFileSize('[image]');
|
||||
$this->assertEquals($maxPhpSize, $retrievedSize, 'Max file size did not default to PHP value');
|
||||
|
||||
// Check the max file size uses the config values
|
||||
$configMaxFileSizes = array(
|
||||
'[image]' => '1k',
|
||||
|
Loading…
Reference in New Issue
Block a user