From 0aaf209c667250b2b5ad5eedd8af0807136e46d4 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 13 Jan 2017 12:55:08 +0100 Subject: [PATCH] Prevent PHP request to get killed when using fclose callback (#26775) * Prevent PHP request to get killed when using fclose callback * Add ignore_user_abort everywhere where the time limit is set to 0 Signed-off-by: Robin Appelman --- apps/dav/appinfo/v1/webdav.php | 1 + apps/dav/appinfo/v2/remote.php | 1 + lib/private/Files/View.php | 2 ++ lib/private/legacy/files.php | 1 + 4 files changed, 5 insertions(+) diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php index f04bf406334..5ad11ceada8 100644 --- a/apps/dav/appinfo/v1/webdav.php +++ b/apps/dav/appinfo/v1/webdav.php @@ -25,6 +25,7 @@ // no php execution timeout for webdav set_time_limit(0); +ignore_user_abort(true); // Turn off output buffering to prevent memory problems \OC_Util::obEnd(); diff --git a/apps/dav/appinfo/v2/remote.php b/apps/dav/appinfo/v2/remote.php index ab05e376503..b4a6578a41a 100644 --- a/apps/dav/appinfo/v2/remote.php +++ b/apps/dav/appinfo/v2/remote.php @@ -21,6 +21,7 @@ */ // no php execution timeout for webdav set_time_limit(0); +ignore_user_abort(true); // Turn off output buffering to prevent memory problems \OC_Util::obEnd(); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 909c49197b8..db21d400b39 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1146,6 +1146,8 @@ class View { $unlockLater = false; if ($this->lockingEnabled && $operation === 'fopen' && is_resource($result)) { $unlockLater = true; + // make sure our unlocking callback will still be called if connection is aborted + ignore_user_abort(true); $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) { if (in_array('write', $hooks)) { $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php index b6c6857a1bf..8c9adad0d49 100644 --- a/lib/private/legacy/files.php +++ b/lib/private/legacy/files.php @@ -148,6 +148,7 @@ class OC_Files { $streamer->sendHeaders($name); $executionTime = intval(OC::$server->getIniWrapper()->getNumeric('max_execution_time')); set_time_limit(0); + ignore_user_abort(true); if ($getType === self::ZIP_FILES) { foreach ($files as $file) { $file = $dir . '/' . $file; -- 2.39.5