Skip to content

Commit 9b0c6c0

Browse files
authored
Merge pull request #3157 from nextcloud/fcloseafterkill
[uc] Prevent PHP request to get killed when using fclose callback (#26775)
2 parents 30c32e0 + 0aaf209 commit 9b0c6c0

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

apps/dav/appinfo/v1/webdav.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
// no php execution timeout for webdav
2727
set_time_limit(0);
28+
ignore_user_abort(true);
2829

2930
// Turn off output buffering to prevent memory problems
3031
\OC_Util::obEnd();

apps/dav/appinfo/v2/remote.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
// no php execution timeout for webdav
2323
set_time_limit(0);
24+
ignore_user_abort(true);
2425

2526
// Turn off output buffering to prevent memory problems
2627
\OC_Util::obEnd();

lib/private/Files/View.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,8 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu
11461146
$unlockLater = false;
11471147
if ($this->lockingEnabled && $operation === 'fopen' && is_resource($result)) {
11481148
$unlockLater = true;
1149+
// make sure our unlocking callback will still be called if connection is aborted
1150+
ignore_user_abort(true);
11491151
$result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) {
11501152
if (in_array('write', $hooks)) {
11511153
$this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);

lib/private/legacy/files.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public static function get($dir, $files, $params = null) {
148148
$streamer->sendHeaders($name);
149149
$executionTime = intval(OC::$server->getIniWrapper()->getNumeric('max_execution_time'));
150150
set_time_limit(0);
151+
ignore_user_abort(true);
151152
if ($getType === self::ZIP_FILES) {
152153
foreach ($files as $file) {
153154
$file = $dir . '/' . $file;

0 commit comments

Comments
 (0)