Improve opcache config check

This commit is contained in:
Luke Towers 2020-04-03 09:08:22 -06:00
parent 86197f59cb
commit 0edde0eb94
1 changed files with 8 additions and 1 deletions

View File

@ -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')) {