From ded9e47dae0ab1e6f1658008c2f5f9285e999c05 Mon Sep 17 00:00:00 2001 From: Nao Date: Sat, 11 Mar 2017 11:32:23 +0100 Subject: [PATCH] + Not sure this'll work 100% because I neither have opcache nor APC installed on my current test server, but apparently it's a good thing to invalidate stuff. Needs testing. (Subs-Cache.php) --- core/app/Subs-Cache.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/app/Subs-Cache.php b/core/app/Subs-Cache.php index c262ba4f..df8025df 100644 --- a/core/app/Subs-Cache.php +++ b/core/app/Subs-Cache.php @@ -1910,12 +1910,23 @@ function cache_put_data($key, $val, $ttl = 120) if (file_put_contents(CACHE_DIR . '/keys/' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data)) @unlink(CACHE_DIR . '/keys/' . $key . '.php'); } + invalidate_opcache($key); } if (!empty($db_show_debug)) $cache_hits[$cache_count]['t'] = microtime(true) - $st; } +function invalidate_opcache($key) +{ + // Invalidate opcode and APC caches if available. + if (function_exists('opcache_invalidate')) + opcache_invalidate(CACHE_DIR . '/keys/' . $key . '.php', true); + + if (function_exists('apc_delete_file')) + apc_delete_file(CACHE_DIR . '/keys/' . $key . '.php'); +} + /** * Attempt to retrieve an item from cache, previously stored with {@link cache_put_data()}. * @@ -1954,7 +1965,10 @@ function cache_get_data($orig_key, $ttl = 120, $put_callback = null) { include(CACHE_DIR . '/keys/' . $key . '.php'); if (empty($valid)) + { @unlink(CACHE_DIR . '/keys/' . $key . '.php'); + invalidate_opcache($key); + } } if (!empty($db_show_debug))