Skip to content

Commit

Permalink
Prevent PHP request to get killed when using fclose callback (#26775)
Browse files Browse the repository at this point in the history
* 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 <robin@icewind.nl>
  • Loading branch information
Vincent Petry authored and icewind1991 committed Jan 23, 2017
1 parent 012e521 commit 0aaf209
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/dav/appinfo/v1/webdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions apps/dav/appinfo/v2/remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,8 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu
$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);
Expand Down
1 change: 1 addition & 0 deletions lib/private/legacy/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public static function get($dir, $files, $params = null) {
$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;
Expand Down

0 comments on commit 0aaf209

Please sign in to comment.