Skip to content

Commit adc2687

Browse files
committed
Fix getMaxFilesize() returning zero
1 parent 27f2b78 commit adc2687

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

File/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function getMaxFilesize()
217217
$sizePostMax = self::parseFilesize(ini_get('post_max_size'));
218218
$sizeUploadMax = self::parseFilesize(ini_get('upload_max_filesize'));
219219

220-
return min([$sizePostMax, $sizeUploadMax]);
220+
return min($sizePostMax ?: PHP_INT_MAX, $sizeUploadMax ?: PHP_INT_MAX);
221221
}
222222

223223
/**

Tests/File/UploadedFileTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,18 @@ public function testIsInvalidIfNotHttpUpload()
281281

282282
$this->assertFalse($file->isValid());
283283
}
284+
285+
public function testGetMaxFilesize()
286+
{
287+
$size = UploadedFile::getMaxFilesize();
288+
289+
$this->assertIsInt($size);
290+
$this->assertGreaterThan(0, $size);
291+
292+
if (0 === (int) ini_get('post_max_size') && 0 === (int) ini_get('upload_max_filesize')) {
293+
$this->assertSame(PHP_INT_MAX, $size);
294+
} else {
295+
$this->assertLessThan(PHP_INT_MAX, $size);
296+
}
297+
}
284298
}

0 commit comments

Comments
 (0)