Created
December 4, 2016 11:58
-
-
Save anonymous/ef0325e2c5023f57c211629a2a45164e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 06a60ee7b72911cf3a61e8e006bae2d0b1e30169 Mon Sep 17 00:00:00 2001 | |
From: Vincent Petry <pvince81@owncloud.com> | |
Date: Fri, 2 Dec 2016 14:55:25 +0100 | |
Subject: [PATCH] Prevent PHP request to get killed when using fclose callback | |
--- | |
lib/private/Files/View.php | 2 ++ | |
1 file changed, 2 insertions(+) | |
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php | |
index f81e3b4..2798ff7 100644 | |
--- a/lib/private/Files/View.php | |
+++ b/lib/private/Files/View.php | |
@@ -1144,6 +1144,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/3rdparty/icewind/streams/src/CallbackWrapper.php b/3rdparty/icewind/streams/src/CallbackWrapper.php | |
index c5847b9..4eef556 100644 | |
--- a/3rdparty/icewind/streams/src/CallbackWrapper.php | |
+++ b/3rdparty/icewind/streams/src/CallbackWrapper.php | |
@@ -107,6 +107,8 @@ class CallbackWrapper extends Wrapper { | |
$result = parent::stream_close(); | |
if (is_callable($this->closeCallback)) { | |
call_user_func($this->closeCallback); | |
+ // prevent further calls by potential PHP 7 GC ghosts | |
+ $this->closeCallback = null; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment