10000 Update SymfonyRequirements.php to better handle infinite values · symfony/requirements-checker@a29a829 · GitHub
[go: up one dir, main page]

Skip to content

Commit a29a829

Browse files
gnutixfabpot
authored andcommitted
Update SymfonyRequirements.php to better handle infinite values
1 parent 9919781 commit a29a829

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/SymfonyRequirements.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,25 @@ function ($cfgValue) { return $cfgValue > 100; },
328328

329329
$this->addPhpConfigRecommendation(
330330
'post_max_size',
331-
$this->getPostMaxSize() < $this->getMemoryLimit(),
331+
function () {
332+
$memoryLimit = $this->getMemoryLimit();
333+
$postMaxSize = $this->getPostMaxSize();
334+
335+
return \INF === $memoryLimit || \INF === $postMaxSize || $memoryLimit > $postMaxSize;
336+
},
332337
true,
333338
'"memory_limit" should be greater than "post_max_size".',
334339
'Set "<strong>memory_limit</strong>" to be greater than "<strong>post_max_size</strong>".'
335340
);
336341

337342
$this->addPhpConfigRecommendation(
338343
'upload_max_filesize',
339-
$this->getUploadMaxFilesize() < $this->getPostMaxSize(),
344+
function () {
345+
$postMaxSize = $this->getPostMaxSize();
346+
$uploadMaxFilesize = $this->getUploadMaxFilesize();
347+
348+
return \INF === $postMaxSize || \INFO === $uploadMaxFilesize || $postMaxSize > $uploadMaxFilesize;
349+
},
340350
true,
341351
'"post_max_size" should be greater than "upload_max_filesize".',
342352
'Set "<strong>post_max_size</strong>" to be greater than "<strong>upload_max_filesize</strong>".'
@@ -363,19 +373,20 @@ class_exists('PDO'),
363373
* (e.g. 16k is converted to 16384 int)
364374
*
365375
* @param string $size - Shorthand size
376+
* @param string $infiniteValue - The infinite value for this setting
366377
*
367378
* @see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
368379
*
369380
* @return int - Converted size
370381
*/
371-
private function convertShorthandSize($size)
382+
private function convertShorthandSize($size, $infiniteValue = '-1')
372383
{
373384
// Initialize
374385
$size = trim($size);
375386
$unit = '';
376387

377388
// Check unlimited alias
378-
if ($size === '-1') {
389+
if ($size === $infiniteValue) {
379390
return \INF;
380391
}
381392

@@ -417,7 +428,7 @@ private function getRealpathCacheSize()
417428
*/
418429
private function getPostMaxSize()
419430
{
420-
return $this->convertShorthandSize(ini_get('post_max_size'));
431+
return $this->convertShorthandSize(ini_get('post_max_size'), '0');
421432
}
422433

423434
/**
@@ -437,7 +448,7 @@ private function getMemoryLimit()
437448
*/
438449
private function getUploadMaxFilesize()
439450
{
440-
return $this->convertShorthandSize(ini_get('upload_max_filesize'));
451+
return $this->convertShorthandSize(ini_get('upload_max_filesize'), '0');
441452
}
442453

443454
private function getComposerRootDir($rootDir)

0 commit comments

Comments
 (0)
0