summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-10 17:21:15 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-02-10 17:21:15 +0100
commit11283c57d9bba055e881293d6958ac9d6033f928 (patch)
tree69970b356c567e58549747692ae6d2e570da35bd /lib
parentbd01ff135acb18d5be817ba153adaab9ac431782 (diff)
parent013feb8da052e7d8f2e1171fb6600d82b3c3ac29 (diff)
downloadnextcloud-server-11283c57d9bba055e881293d6958ac9d6033f928.tar.gz
nextcloud-server-11283c57d9bba055e881293d6958ac9d6033f928.zip
Merge pull request #11056 from AdamWill/9885-opcode
add function to invalidate one opcache file, use it if possible #9885
Diffstat (limited to 'lib')
-rw-r--r--lib/private/config.php7
-rw-r--r--lib/private/util.php26
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