Skip to content

Commit

Permalink
fix #825 return INF instead of -1 from php ini values
Browse files Browse the repository at this point in the history
  • Loading branch information
ximex committed Sep 12, 2018
1 parent 18c185e commit 1c5d94f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions adm_program/modules/preferences/preferences.php
Expand Up @@ -717,7 +717,7 @@ function getPreferencePanel($group, $id, $title, $icon, $body)
$formSystemInformation->addStaticControl('directory_protection', $gL10n->get('SYS_DIRECTORY_PROTECTION'), $html);

$postMaxSize = PhpIniUtils::getPostMaxSize();
if($postMaxSize === -1)
if(is_infinite($postMaxSize))
{
$html = getStaticText('warning', $gL10n->get('SYS_NOT_SET'));
}
Expand All @@ -728,7 +728,7 @@ function getPreferencePanel($group, $id, $title, $icon, $body)
$formSystemInformation->addStaticControl('post_max_size', $gL10n->get('SYS_POST_MAX_SIZE'), $html);

$memoryLimit = PhpIniUtils::getMemoryLimit();
if($memoryLimit === -1)
if(is_infinite($memoryLimit))
{
$html = getStaticText('warning', $gL10n->get('SYS_NOT_SET'));
}
Expand All @@ -749,7 +749,7 @@ function getPreferencePanel($group, $id, $title, $icon, $body)
$formSystemInformation->addStaticControl('file_uploads', $gL10n->get('SYS_FILE_UPLOADS'), $html);

$fileUploadMaxFileSize = PhpIniUtils::getFileUploadMaxFileSize();
if($fileUploadMaxFileSize === -1)
if(is_infinite($fileUploadMaxFileSize))
{
$html = getStaticText('warning', $gL10n->get('SYS_NOT_SET'));
}
Expand Down
8 changes: 4 additions & 4 deletions adm_program/system/classes/PhpIniUtils.php
Expand Up @@ -40,12 +40,12 @@ public static function getDisabledFunctions()
*/
public static function checkSizeLimits()
{
return (self::getMemoryLimit() === -1 || self::getMemoryLimit() >= self::getPostMaxSize())
&& (self::getPostMaxSize() === -1 || self::getPostMaxSize() >= self::getFileUploadMaxFileSize());
return (is_infinite(self::getMemoryLimit()) || self::getMemoryLimit() >= self::getPostMaxSize())
&& (is_infinite(self::getPostMaxSize()) || self::getPostMaxSize() >= self::getFileUploadMaxFileSize());
}

/**
* Returns the calculated bytes of a string or -1 if unlimited.
* Returns the calculated bytes of a string or INF if unlimited.
* @param string $data Could be empty string (not set), "-1" (no limit) or a float with a unit.
* Units could be K for Kilobyte, M for Megabyte, G for Gigabyte or T for Terabyte.
* @param int $multi Factor to multiply. Default: 1024
Expand All @@ -55,7 +55,7 @@ private static function getBytesFromSize($data, $multi = self::BYTES_UNIT_FACTOR
{
if ($data === '' || $data === '-1')
{
return -1;
return INF;
}

$value = (float) substr($data, 0, -1);
Expand Down
2 changes: 1 addition & 1 deletion adm_program/system/function.php
Expand Up @@ -276,7 +276,7 @@ function admFuncProcessableImageSize()
{
$memoryLimit = PhpIniUtils::getMemoryLimit();
// if memory_limit is disabled in php.ini
if ($memoryLimit === -1)
if (is_infinite($memoryLimit))
{
$memoryLimit = 128 * 1024 * 1024; // 128MB
}
Expand Down

0 comments on commit 1c5d94f

Please sign in to comment.