aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicke Nordin <kano@sunet.se>2022-04-29 08:21:53 +0200
committerMicke Nordin <kano@sunet.se>2022-04-29 14:50:57 +0200
commit259664468a009b03d6d974613e47f0e140f7332b (patch)
tree145f7bdd54ffb457285fdb83b96295fc8045a225
parent8367b02785acd920db244ecb745517820ed9ff91 (diff)
downloadnextcloud-server-259664468a009b03d6d974613e47f0e140f7332b.tar.gz
nextcloud-server-259664468a009b03d6d974613e47f0e140f7332b.zip
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 <kano@sunet.se>
-rw-r--r--lib/base.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/base.php b/lib/base.php
index 21889272dd7..d73fa92abef 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -623,16 +623,32 @@ 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 web server and php configuration.
- //Let´s try to overwrite some defaults anyway
+ //this doesn´t work always depending on the webserver and php configuration.
+ //Let´s try to overwrite some defaults if they are smaller than 1 hour
+ // One hour is 3600 seconds
+ $time_limit = 3600;
+
+ $max_execution_time_from_ini = @ini_get('max_execution_time');
+ $biggest_max_execution_time = $time_limit;
+ if (isset($max_execution_time_from_ini)) {
+ $biggest_max_execution_time = max($time_limit, intval($max_execution_time_from_ini));
+ }
+ @ini_set('max_execution_time', strval($biggest_max_execution_time));
+
+ $max_input_time_from_ini = @ini_get('max_input_time');
+ $biggest_max_input_time = $time_limit;
+ if (isset($max_input_time_from_ini)) {
+ $biggest_max_input_time = max($time_limit, intval($max_input_time_from_ini));
+ }
+ @ini_set('max_input_time', strval($biggest_max_input_time));
- //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();