From 9083f124f1d893e0b3b3e7a91eefcf7393cc72b1 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 25 Nov 2016 16:39:25 +0100 Subject: [PATCH] Prevent PHP7 GC to kill normalizedPathCache too early --- lib/private/Files/Filesystem.php | 2 +- lib/private/Files/View.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index 332071571a3e..edabdda9469b 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -81,7 +81,7 @@ class Filesystem { static private $usersSetup = array(); - static private $normalizedPathCache = null; + static public $normalizedPathCache = null; static private $listeningForProviders = false; diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index f81e3b4ca7e9..cdb02f1b030f 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1144,12 +1144,15 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu $unlockLater = false; if ($this->lockingEnabled && $operation === 'fopen' && is_resource($result)) { $unlockLater = true; - $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) { + // create additional reference to avoid PHP 7's hungry GC to discard it too early... + $normalizedPathCache = \OC\Files\Filesystem::$normalizedPathCache; + $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path, &$normalizedPathCache) { if (in_array('write', $hooks)) { $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); } else if (in_array('read', $hooks)) { $this->unlockFile($path, ILockingProvider::LOCK_SHARED); } + $normalizedPathCache = null; }); }