From 4092599d15892f6f31dccfefb811b5966acaccc4 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Fri, 29 Apr 2022 08:21:53 +0200 Subject: [PATCH 1/4] Respect user settings in php.ini if they are big enough In the admin guide: * https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html it is mentioned that you can tweek: * max_input_time * max_execution_time in order to enable larger file uploads. However, the current codebase will hard code these values to one hour, no matter what the user sets in php.ini. This patch will allow the user to set these settings in php.ini and they will be respected, if and only if, they are set to something bigger than 3600 seconds. Signed-off-by: Micke Nordin --- lib/base.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/base.php b/lib/base.php index c0b26e96851..9c0ab305f79 100644 --- a/lib/base.php +++ b/lib/base.php @@ -609,16 +609,16 @@ class OC { throw new \RuntimeException('Could not set timezone to UTC'); } + //try to configure php to enable big file uploads. //this doesn´t work always depending on the webserver and php configuration. //Let´s try to overwrite some defaults anyway - //try to set the maximum execution time to 60min + //try to set the maximum execution time to the largest time limit we have if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { - @set_time_limit(3600); + $biggest_time_limit = max($time_limit, $biggest_max_execution_time, $biggest_max_input_time); + @set_time_limit($biggest_time_limit); } - @ini_set('max_execution_time', '3600'); - @ini_set('max_input_time', '3600'); self::setRequiredIniValues(); self::handleAuthHeaders(); From 7fee1078f263e50575b869da27698cec940210bf Mon Sep 17 00:00:00 2001 From: Mikael Nordin Date: Sat, 30 Apr 2022 16:30:11 +0200 Subject: [PATCH 2/4] Simpler version as proposed by @artonage Co-authored-by: Louis <6653109+artonge@users.noreply.github.com> Signed-off-by: Micke Nordin --- lib/base.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index 9c0ab305f79..fc96737db0a 100644 --- a/lib/base.php +++ b/lib/base.php @@ -616,8 +616,7 @@ class OC { //try to set the maximum execution time to the largest time limit we have if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { - $biggest_time_limit = max($time_limit, $biggest_max_execution_time, $biggest_max_input_time); - @set_time_limit($biggest_time_limit); + @set_time_limit(strval(max(intval(@ini_get('max_execution_time')),intval(@ini_get('max_input_time'))))); } self::setRequiredIniValues(); From 6601fbd8efc8943afa187ba422bc975482ef5073 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 16 May 2022 10:14:53 +0200 Subject: [PATCH 3/4] Fix suggestions by @artonage Signed-off-by: Micke Nordin --- lib/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index fc96737db0a..dd28f2bb254 100644 --- a/lib/base.php +++ b/lib/base.php @@ -616,7 +616,7 @@ class OC { //try to set the maximum execution time to the largest time limit we have if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { - @set_time_limit(strval(max(intval(@ini_get('max_execution_time')),intval(@ini_get('max_input_time'))))); + @set_time_limit(max(intval(@ini_get('max_execution_time')), intval(@ini_get('max_input_time')))); } self::setRequiredIniValues(); From 356c732904d24f8eab722352529e9f97d4f7272b Mon Sep 17 00:00:00 2001 From: szaimen Date: Tue, 30 Aug 2022 18:36:50 +0200 Subject: [PATCH 4/4] fix the backport Signed-off-by: szaimen --- lib/base.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index dd28f2bb254..50762f7a7ca 100644 --- a/lib/base.php +++ b/lib/base.php @@ -612,7 +612,15 @@ class OC { //try to configure php to enable big file uploads. //this doesn´t work always depending on the webserver and php configuration. - //Let´s try to overwrite some defaults anyway + //Let´s try to overwrite some defaults if they are smaller than 1 hour + + if (intval(@ini_get('max_execution_time') ?? 0) < 3600) { + @ini_set('max_execution_time', strval(3600)); + } + + if (intval(@ini_get('max_input_time') ?? 0) < 3600) { + @ini_set('max_input_time', strval(3600)); + } //try to set the maximum execution time to the largest time limit we have if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {