From 0edde0eb940516ca2678668630603e5e66edcc7b Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Fri, 3 Apr 2020 09:08:22 -0600 Subject: [PATCH] Improve opcache config check --- modules/cms/classes/CodeParser.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/cms/classes/CodeParser.php b/modules/cms/classes/CodeParser.php index 033832203..f2f5e0ad7 100644 --- a/modules/cms/classes/CodeParser.php +++ b/modules/cms/classes/CodeParser.php @@ -334,7 +334,14 @@ class CodeParser * Compile cached file into bytecode cache */ if (Config::get('cms.forceBytecodeInvalidation', false)) { - if (function_exists('opcache_invalidate') && ini_get('opcache.enable')) { + $opcache_enabled = ini_get('opcache.enable'); + $opcache_path = trim(ini_get('opcache.restrict_api')); + + if (!empty($opcache_path) && !starts_with(__FILE__, $opcache_path)) { + $opcache_enabled = false; + } + + if (function_exists('opcache_invalidate') && $opcache_enabled) { opcache_invalidate($path, true); } elseif (function_exists('apc_compile_file')) {