summaryrefslogtreecommitdiffstats
path: root/lib/private/config.php
diff options
context:
space:
mode:
authorAdam Williamson <awilliam@redhat.com>2014-09-12 23:33:18 -0700
committerAdam Williamson <awilliam@redhat.com>2014-11-06 17:58:58 -0800
commit3b4823d89c03e54917ce6844dfbd227c8b4d6adc (patch)
treeaca3b6e69ef569a71f330f68df5677bf0c573687 /lib/private/config.php
parentd383c45c134eec554af3fe579e40ef6ca5913b3f (diff)
downloadnextcloud-server-3b4823d89c03e54917ce6844dfbd227c8b4d6adc.tar.gz
nextcloud-server-3b4823d89c03e54917ce6844dfbd227c8b4d6adc.zip
add function to invalidate one opcache file, use it if possible #9885
Issue #9885 appears to be triggered by ownCloud invalidating the entire PHP opcache. Testing indicates it can be avoided by only invalidating the single file that was written from the opcache, instead of clearing the whole thing. In general it is more efficient to invalidate only the single file that was changed, rather than the whole cache. This adds a deleteFromOpcodeCache() function which invalidates a single file from the opcache if possible, returning true if the underlying function returns true (which may mean 'success', or 'file does not exist', or 'file exists but is not in opcache', all of which are OK to treat as good for our purposes). It also changes writeData() in config.php to try using deleteFromOpcodeCache() and only fall back on clearOpcodeCache() if that fails.
Diffstat (limited to 'lib/private/config.php')
-rw-r--r--lib/private/config.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/private/config.php b/lib/private/config.php
index f0548442ab5..8bb2a5c48d1 100644
--- a/lib/private/config.php
+++ b/lib/private/config.php
@@ -207,8 +207,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->configFilename)) {
+ // But if that doesn't work, clear the whole cache.
+ \OC_Util::clearOpcodeCache();
+ }
}
}