MDL-40415 add explicit OPcache support

This commit is contained in:
Petr Škoda
2013-07-04 19:32:26 +02:00
parent f8e6e5bc30
commit c05a50992e
17 changed files with 136 additions and 0 deletions
+18
View File
@@ -142,6 +142,7 @@ class core_component {
@chmod($cachefile, $CFG->filepermissions);
}
@unlink($cachefile.'.tmp'); // Just in case anything fails (race condition).
self::invalidate_opcode_php_cache($cachefile);
}
}
@@ -735,4 +736,21 @@ $cache = '.var_export($cache, true).';
}
return $return;
}
/**
* Invalidate opcode cache for given file, this is intended for
* php files that are stored in dataroot.
*
* Note: we need it here because this class must be self-contained.
*
* @param string $file
*/
public static function invalidate_opcode_php_cache($file) {
if (function_exists('opcache_invalidate')) {
if (!file_exists($file)) {
return;
}
opcache_invalidate($file, true);
}
}
}