From b669f5706800ccd4e0045f556617a75c1c9f1756 Mon Sep 17 00:00:00 2001 From: Miguel Dantas Date: Tue, 18 Jun 2019 20:57:30 +0100 Subject: [PATCH] [CORE] Fixed common_get_preferred_php_upload_limit, because some values in php.ini can be -1 or 0 for unlimited --- lib/framework.php | 2 +- lib/util.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/framework.php b/lib/framework.php index 1077256605..385acb36b2 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -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); diff --git a/lib/util.php b/lib/util.php index d0131be2ae..e02d73ea70 100644 --- a/lib/util.php +++ b/lib/util.php @@ -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'))); -- 2.39.5