mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
5815c8344b4d645323d92dab3abb5b8a7d8dd605
This PR was squashed before being merged into the 1.x branch (closes #1796).
Discussion
----------
OPcache support fix
According this recipe http://twig.sensiolabs.org/doc/recipes.html#refreshing-modified-templates-when-opcache-or-apc-is-enabled when using OPcache:
```
class Twig_Environment_APC extends Twig_Environment
{
protected function writeCacheFile($file, $content)
{
parent::writeCacheFile($file, $content);
// Compile cached file into bytecode cache
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);
}
}
}
```
it takes an error:
```
Cannot redeclare class __TwigTemplate_12e7606b10ee267fa4174f660f86451aed936cc5680300a6442092f337c910cf
```
This is due to fact that the function ```opcache_compile_file($file)``` executes the file. But it should not do so in accordance with the documentation: http://php.net/manual/en/function.opcache-compile-file.php
There is a bug report: https://bugs.php.net/bug.php?id=66066 (since 2013 👎).
This patch prevents reexecution of the compiled template.
Commits
-------
2c4af24 OPcache support fix
Twig, the flexible, fast, and secure template language for PHP ============================================================== Twig is a template language for PHP, released under the new BSD license (code and documentation). Twig uses a syntax similar to the Django and Jinja template languages which inspired the Twig runtime environment. More Information ---------------- Read the `documentation`_ for more information. .. _documentation: http://twig.sensiolabs.org/documentation
Description
Languages
PHP
99.9%