mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7000 from kinglozzer/uploadfield-size-ini
FIX: Upload_Validator failed to fetch max size from PHP ini values (fixes #6999)
This commit is contained in:
commit
7cf7a7094c
@ -396,7 +396,7 @@ class Upload_Validator {
|
|||||||
if (empty($this->allowedMaxFileSize)) {
|
if (empty($this->allowedMaxFileSize)) {
|
||||||
// Set default max file sizes if there isn't
|
// Set default max file sizes if there isn't
|
||||||
$fileSize = Config::inst()->get('Upload_Validator', 'default_max_file_size');
|
$fileSize = Config::inst()->get('Upload_Validator', 'default_max_file_size');
|
||||||
if (isset($fileSize)) {
|
if (!empty($fileSize)) {
|
||||||
$this->setAllowedMaxFileSize($fileSize);
|
$this->setAllowedMaxFileSize($fileSize);
|
||||||
} else {
|
} else {
|
||||||
// When no default is present, use maximum set by PHP
|
// When no default is present, use maximum set by PHP
|
||||||
|
@ -134,6 +134,12 @@ class UploadTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testGetAllowedMaxFileSize() {
|
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
|
// Check the max file size uses the config values
|
||||||
$configMaxFileSizes = array(
|
$configMaxFileSizes = array(
|
||||||
'[image]' => '1k',
|
'[image]' => '1k',
|
||||||
|
Loading…
Reference in New Issue
Block a user