From 0024b67aaf1b5fd79a2e73789a4c903364162e54 Mon Sep 17 00:00:00 2001 From: Ko- Date: Sat, 11 Mar 2017 17:04:21 +0100 Subject: [PATCH] Check that set_time_limit is not disabled before calling it Signed-off-by: Ko- --- apps/dav/appinfo/v1/webdav.php | 4 +++- apps/dav/appinfo/v2/remote.php | 4 +++- console.php | 4 +++- core/ajax/update.php | 5 ++++- cron.php | 4 +++- lib/base.php | 4 +++- lib/private/legacy/files.php | 4 +++- settings/Controller/EncryptionController.php | 4 +++- 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php index 5ad11ceada8..32f93b27760 100644 --- a/apps/dav/appinfo/v1/webdav.php +++ b/apps/dav/appinfo/v1/webdav.php @@ -24,7 +24,9 @@ */ // no php execution timeout for webdav -set_time_limit(0); +if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); +} ignore_user_abort(true); // Turn off output buffering to prevent memory problems diff --git a/apps/dav/appinfo/v2/remote.php b/apps/dav/appinfo/v2/remote.php index b4a6578a41a..3a00c8006ec 100644 --- a/apps/dav/appinfo/v2/remote.php +++ b/apps/dav/appinfo/v2/remote.php @@ -20,7 +20,9 @@ * */ // no php execution timeout for webdav -set_time_limit(0); +if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); +} ignore_user_abort(true); // Turn off output buffering to prevent memory problems diff --git a/console.php b/console.php index fb410ee6983..47cc2edf018 100644 --- a/console.php +++ b/console.php @@ -48,7 +48,9 @@ try { require_once __DIR__ . '/lib/base.php'; // set to run indefinitely if needed - set_time_limit(0); + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); + } if (!OC::$CLI) { echo "This script can be run from the command line only" . PHP_EOL; diff --git a/core/ajax/update.php b/core/ajax/update.php index fca40477d60..37abdc5dc3b 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -29,7 +29,10 @@ */ use Symfony\Component\EventDispatcher\GenericEvent; -set_time_limit(0); +if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); +} + require_once '../../lib/base.php'; $l = \OC::$server->getL10N('core'); diff --git a/cron.php b/cron.php index feb680bd9c2..f6c52446d3c 100644 --- a/cron.php +++ b/cron.php @@ -84,7 +84,9 @@ try { if (OC::$CLI) { // set to run indefinitely if needed - set_time_limit(0); + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); + } // the cron job must be executed with the right user if (!function_exists('posix_getuid')) { diff --git a/lib/base.php b/lib/base.php index 68178b06c5b..04b6d82b1df 100644 --- a/lib/base.php +++ b/lib/base.php @@ -616,7 +616,9 @@ class OC { //Let´s try to overwrite some defaults anyway //try to set the maximum execution time to 60min - @set_time_limit(3600); + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(3600); + } @ini_set('max_execution_time', 3600); @ini_set('max_input_time', 3600); diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php index 8c9adad0d49..ed3aa719409 100644 --- a/lib/private/legacy/files.php +++ b/lib/private/legacy/files.php @@ -147,7 +147,9 @@ class OC_Files { $streamer->sendHeaders($name); $executionTime = intval(OC::$server->getIniWrapper()->getNumeric('max_execution_time')); - set_time_limit(0); + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); + } ignore_user_abort(true); if ($getType === self::ZIP_FILES) { foreach ($files as $file) { diff --git a/settings/Controller/EncryptionController.php b/settings/Controller/EncryptionController.php index cda50853fdc..0c8dd529a7d 100644 --- a/settings/Controller/EncryptionController.php +++ b/settings/Controller/EncryptionController.php @@ -105,7 +105,9 @@ class EncryptionController extends Controller { */ public function startMigration() { // allow as long execution on the web server as possible - set_time_limit(0); + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { + @set_time_limit(0); + } try { -- 2.39.5