parent
8caf3c5d02
commit
b2301a8056
|
|
@ -316,4 +316,16 @@ return [
|
|||
|
||||
'enableCsrfProtection' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Force bytecode invalidation
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using OPcache with opcache.validate_timestamps set to 0 or APC
|
||||
| with apc.stat set to 0 and Twig cache enabled, clearing the template
|
||||
| cache won't update the cache, set to true to get around this.
|
||||
|
|
||||
*/
|
||||
|
||||
'forceBytecodeInvalidation' => true,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -334,11 +334,13 @@ class CodeParser
|
|||
/*
|
||||
* Compile cached file into bytecode cache
|
||||
*/
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($path, true);
|
||||
}
|
||||
elseif (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($path);
|
||||
if (Config::get('cms.forceBytecodeInvalidation', false)) {
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($path, true);
|
||||
}
|
||||
elseif (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use Response;
|
|||
use Exception;
|
||||
use BackendAuth;
|
||||
use Twig_Environment;
|
||||
use Twig_Cache_Filesystem;
|
||||
use Cms\Twig\Loader as TwigLoader;
|
||||
use Cms\Twig\DebugExtension;
|
||||
use Cms\Twig\Extension as CmsTwigExtension;
|
||||
|
|
@ -484,14 +485,20 @@ class Controller
|
|||
{
|
||||
$this->loader = new TwigLoader;
|
||||
|
||||
$useCache = !Config::get('cms.twigNoCache');
|
||||
$isDebugMode = Config::get('app.debug', false);
|
||||
$forceBytecode = Config::get('cms.forceBytecodeInvalidation', false);
|
||||
|
||||
$options = [
|
||||
'auto_reload' => true,
|
||||
'debug' => $isDebugMode,
|
||||
];
|
||||
if (!Config::get('cms.twigNoCache')) {
|
||||
$options['cache'] = storage_path().'/cms/twig';
|
||||
|
||||
if ($useCache) {
|
||||
$options['cache'] = new Twig_Cache_Filesystem(
|
||||
storage_path().'/cms/twig',
|
||||
$forceBytecode ? Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION : 0
|
||||
);
|
||||
}
|
||||
|
||||
$this->twig = new Twig_Environment($this->loader, $options);
|
||||
|
|
|
|||
Loading…
Reference in New Issue