8000 bug #33157 Fix getMaxFilesize() returning zero (ausi) · symfony/symfony@b382e62 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b382e62

Browse files
committed
bug #33157 Fix getMaxFilesize() returning zero (ausi)
This PR was merged into the 3.4 branch. Discussion ---------- Fix getMaxFilesize() returning zero | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32790 | License | MIT With #32790 a BC break got introduced. Previously an empty `upload_max_filesize` returned `PHP_INT_MAX` but after the changes from #32790 it returns `0`. Setting `upload_max_filesize` or `post_max_size` to `0` or `''` disables the limit so for both cases `PHP_INT_MAX` should be returned. Commits ------- f4c2ea5 Fix getMaxFilesize() returning zero
2 parents 7ae7a66 + f4c2ea5 commit b382e62

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/HttpFoundation/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
/**

src/Symfony/Component/HttpFoundation/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)
0