[CORE] Fixed common_get_preferred_php_upload_limit, because some values in php.ini can be -1 or 0 for unlimited

This commit is contained in:
Miguel Dantas 2019-06-18 20:57:30 +01:00 committed by Diogo Cordeiro
parent ccebe536b3
commit b669f57068
2 changed files with 6 additions and 4 deletions

View File

@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die();
define('GNUSOCIAL_ENGINE', 'GNU social');
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
define('GNUSOCIAL_BASE_VERSION', '1.22.0');
define('GNUSOCIAL_BASE_VERSION', '1.22.1');
define('GNUSOCIAL_LIFECYCLE', 'dev'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);

View File

@ -2660,7 +2660,9 @@ function common_strip_html($html, $trim=true, $save_whitespace=false)
*/
function _common_size_str_to_int($size) : int
{
if (empty($size)) {
// `memory_limit` can be -1 and `post_max_size` can be 0
// for unlimited. Consistency.
if (empty($size) || $size === '-1' || $size === '0') {
return 5000000;
}
@ -2689,9 +2691,9 @@ function _common_size_str_to_int($size) : int
/**
* Uses `_common_size_str_to_int()` to find the smallest value for uploads in php.ini
*
* @returns int
* @return int
*/
function common_get_preferred_php_upload_limit() {
function common_get_preferred_php_upload_limit() : int {
return min(_common_size_str_to_int(ini_get('post_max_size')),
_common_size_str_to_int(ini_get('upload_max_filesize')),
_common_size_str_to_int(ini_get('memory_limit')));