diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-02-10 17:21:15 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-02-10 17:21:15 +0100 |
commit | 11283c57d9bba055e881293d6958ac9d6033f928 (patch) | |
tree | 69970b356c567e58549747692ae6d2e570da35bd /lib/private/util.php | |
parent | bd01ff135acb18d5be817ba153adaab9ac431782 (diff) | |
parent | 013feb8da052e7d8f2e1171fb6600d82b3c3ac29 (diff) | |
download | nextcloud-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/private/util.php')
-rw-r--r-- | lib/private/util.php | 26 |
1 files changed, 26 insertions, 0 deletions
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 |