diff options
-rw-r--r-- | lib/private/config.php | 7 | ||||
-rw-r--r-- | lib/private/util.php | 26 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/private/config.php b/lib/private/config.php index 31e536221dd..5c8cc89f0f0 100644 --- a/lib/private/config.php +++ b/lib/private/config.php @@ -236,8 +236,11 @@ class Config { flock($filePointer, LOCK_UN); fclose($filePointer); - // Clear the opcode cache - \OC_Util::clearOpcodeCache(); + // Try invalidating the opcache just for the file we wrote... + if (!\OC_Util::deleteFromOpcodeCache($this->configFilePath)) { + // But if that doesn't work, clear the whole cache. + \OC_Util::clearOpcodeCache(); + } } } diff --git a/lib/private/util.php b/lib/private/util.php index 9a01ca3ac95..988ea5c7c7b 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1272,6 +1272,32 @@ class OC_Util { } /** + * Clear a single file from the opcode cache + * This is useful for writing to the config file + * in case the opcode cache does not re-validate files + * Returns true if successful, false if unsuccessful: + * caller should fall back on clearing the entire cache + * with clearOpcodeCache() if unsuccessful + * + * @param string $path the path of the file to clear from the cache + * @return bool true if underlying function returns true, otherwise false + */ + public static function deleteFromOpcodeCache($path) { + $ret = false; + if ($path) { + // APC >= 3.1.1 + if (function_exists('apc_delete_file')) { + $ret = @apc_delete_file($path); + } + // Zend OpCache >= 7.0.0, PHP >= 5.5.0 + if (function_exists('opcache_invalidate')) { + $ret = opcache_invalidate($path); + } + } + return $ret; + } + + /** * Clear the opcode cache if one exists * This is necessary for writing to the config file * in case the opcode cache does not re-validate files |