Merge branch '1.x'

* 1.x:
  fixed typos and CS
  [doc/recipes] Added OPcache support
  Remove broken code
This commit is contained in:
Fabien Potencier
2015-08-15 21:53:57 +02:00
2 changed files with 13 additions and 23 deletions
+12 -7
View File
@@ -274,13 +274,14 @@ If you iterate over a set of files, you can pass the filename to the
is enforced during template rendering (as Twig needs the context for some
checks like allowed methods on objects).
Refreshing modified Templates when APC is enabled and apc.stat = 0
------------------------------------------------------------------
Refreshing modified Templates when OPcache or APC is enabled
------------------------------------------------------------
When using APC with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing
the template cache won't update the APC cache. To get around this, one can
extend ``Twig_Environment`` and force the update of the APC cache when Twig
rewrites the cache::
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. To get around this, one can extend
``Twig_Environment`` and force the update of the cache when Twig rewrites the
cache::
class Twig_Environment_APC extends Twig_Environment
{
@@ -289,7 +290,11 @@ rewrites the cache::
parent::writeCacheFile($file, $content);
// Compile cached file into bytecode cache
apc_compile_file($file);
if (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) {
opcache_compile_file($file);
} elseif (extension_loaded('apc') && ini_get('apc.enabled')) {
apc_compile_file($file);
}
}
}
+1 -16
View File
@@ -402,22 +402,7 @@ class Twig_Node_Module extends Twig_Node
->raw(");\n")
;
} else {
$compiler
->write(sprintf('%s = ', $var))
->subcompile($node)
->raw(";\n")
->write(sprintf('if (!%s', $var))
->raw(" instanceof Twig_Template) {\n")
->indent()
->write(sprintf('%s = $this->loadTemplate(%s')
->raw(', ')
->repr($compiler->getFilename())
->raw(', ')
->repr($node->getLine())
->raw(");\n", $var, $var))
->outdent()
->write("}\n")
;
throw new LogicException('Trait templates can only be constant nodes');
}
}
}