Commit Graph

2672 Commits

Author SHA1 Message Date
Fabien Potencier 9df64cf582 minor #1827 No need to check modification time when opcache_invalidate (Tobion)
This PR was merged into the 1.x branch.

Discussion
----------

No need to check modification time when opcache_invalidate

- We know the file is new
- No need to check if opcache/apc is enabled as these methods will just return false in this case

Commits
-------

f63099e No need to check modification time when opcache_invalidate
2015-09-13 18:55:45 +02:00
Tobias Schultze f63099e00b No need to check modification time when opcache_invalidate
- We know the file is new
- No need to check if opcache/apc is enabled as these methods will just return false in this case
2015-09-13 18:50:03 +02:00
Fabien Potencier b673f65d34 feature #1823 rewrote the recipes about APC and opcache to avoid deprecation notices (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

rewrote the recipes about APC and opcache to avoid deprecation notices

Commits
-------

96a54b3 added an option to force PHP bytecode invalidation when writing a compiled template into the cache
e9b0802 rewrote the recipes about APC and opcache to avoid deprecation notices
2015-09-13 13:17:46 +02:00
Fabien Potencier 257c354b97 minor #1826 added a recipe about how to render a template stored as a string (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

added a recipe about how to render a template stored as a string

Commits
-------

77fed4e added a recipe about how to render a template stored as a string
2015-09-13 13:17:13 +02:00
Fabien Potencier 77fed4e659 added a recipe about how to render a template stored as a string 2015-09-13 12:37:19 +02:00
Fabien Potencier 96a54b3f40 added an option to force PHP bytecode invalidation when writing a compiled template into the cache 2015-09-13 12:26:27 +02:00
Fabien Potencier e9b08026b3 rewrote the recipes about APC and opcache to avoid deprecation notices 2015-09-13 12:12:56 +02:00
Fabien Potencier b5c7f5cd5a added a note about Twig_Loader_String alternatives 2015-09-13 08:53:43 +02:00
Fabien Potencier fc2dafc2de bug #1825 Profiler root duration fix (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Profiler root duration fix

When using the Twig profiler, the root node is a bit special and the duration should really be the sum of the children duration. That should fix #1792

Commits
-------

f1e963c fixed the profiler duration for the root node
2015-09-12 19:43:05 +02:00
Fabien Potencier 5126cbff91 feature #1822 changed the arguments of generateKey (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

changed the arguments of generateKey

We now pass the template name and the template class, which seems much better from a UX standpoint.

Passing the prefix was really just a hack and an implementation leak to be able to determine the variable part of the class name and generate sub-directories for templates. Now, we generate the cache key by taking the last characters instead of the first ones, to avoid the need for the class prefix.

That should also make Drupal happy :)

Commits
-------

c2e75ff changed the arguments of generateKey
0157315 deprecated Twig_Environment::getTemplateClassPrefix
2015-09-12 19:42:00 +02:00
Fabien Potencier c2e75ff88a changed the arguments of generateKey 2015-09-12 15:34:55 +02:00
Fabien Potencier 0157315e59 deprecated Twig_Environment::getTemplateClassPrefix 2015-09-12 15:34:51 +02:00
Fabien Potencier 0433e79cd5 bug #1824 added enabled extension names in the generated template class names (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

added enabled extension names in the generated template class names

The generated template class names now take into account enabled extensions.

fixes #1742

Commits
-------

550a384 added enabled extension names in the generated template class names
2015-09-12 14:59:28 +02:00
Fabien Potencier e3c1e17d09 removed empty () in an error message 2015-09-12 14:52:14 +02:00
Fabien Potencier 550a384412 added enabled extension names in the generated template class names 2015-09-12 14:43:01 +02:00
Fabien Potencier f1e963c2dc fixed the profiler duration for the root node 2015-09-12 12:46:16 +02:00
Fabien Potencier c6ad6feda4 minor #1820 no need to call setTimezone on a current date (Tobion)
This PR was merged into the 1.x branch.

Discussion
----------

no need to call setTimezone on a current date

Avoiding unnecessary method calls.

- When retrieving the current time, there is no point changing the timezone from default to the specified timezone, e.g. if you just use twigs `date()` function.
- When dealing with timestamps, the initial timezone is irrelevant as well since unix timstamps are always in GMT.

Commits
-------

163f42e no need to call setTimezone on a current date
2015-09-12 10:53:17 +02:00
Fabien Potencier de909d4958 minor #1818 use str_replace instead of strtr to escape the source in the template (Tobion)
This PR was merged into the 1.x branch.

Discussion
----------

use str_replace instead of strtr to escape the source in the template

strtr is really slow when used this way.

Benchmark https://3v4l.org/PXWDg/perf#tabs vs https://3v4l.org/iuq1Z/perf#tabs

strtr is only slightly faster when used with a byte-by-byte replacement as done in https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Lexer.php#L263

Commits
-------

19ef9a3 use str_replace instead of strtr to escape the source in the template
2015-09-12 10:51:54 +02:00
Tobias Schultze 163f42ea5c no need to call setTimezone on a current date 2015-09-11 21:40:19 +02:00
Tobias Schultze 19ef9a32d5 use str_replace instead of strtr to escape the source in the template 2015-09-11 19:40:31 +02:00
Fabien Potencier 336a319246 bug #1817 Fix inlining of sources with CRLF (nicolas-grekas)
This PR was merged into the 1.x branch.

Discussion
----------

Fix inlining of sources with CRLF

Commits
-------

7e666cb Fix inlining of sources with CRLF
2015-09-11 17:57:54 +02:00
Nicolas Grekas 7e666cba8d Fix inlining of sources with CRLF 2015-09-11 17:49:20 +02:00
Fabien Potencier 4d6d3a5944 fixed deprecation docs 2015-09-11 16:58:04 +02:00
Fabien Potencier 83152dc2b6 fixed CHANGELOG 2015-09-11 16:52:36 +02:00
Fabien Potencier 87e27b6a26 feature #1812 Extracted the filesystem cache to its own class (andrewtch, fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Extracted the filesystem cache to its own class

Twig caches the compiled PHP classes on the filesystem. This is **always** the best strategy as it allows Twig to automatically benefit from PHP opcache/APC. But overriding how the classes are stored on the filesystem is difficult with the current way, so this PR proposes to extract this logic to its own class (that should allow Drupal to stop copy/pasting some Twig code and accessing private code - see #1811).

This PR also unifies the no-cache feature by extracting it to its own class as well.

BC is kept and the `false` and `$dir` caching strategies are still supported.

The `Twig_Cache_Interface` can be used to create other cache classes, but that's not documented and should only be used with extreme care (performance-wise). It means that Twig itself will **never** ship with other implementations like Memcache, Redis, whatever storage is hype nowadays. This should fix #1421 (this PR builds on top of it), #1573, #1415, #741, #728.

Commits
-------

cacfb06 added a cache interface for templates
04cc7e4 Implemented filesystem cache, one and only (see #1415)
2015-09-11 16:41:19 +02:00
Fabien Potencier cacfb069b2 added a cache interface for templates 2015-09-11 16:24:57 +02:00
Andrew Tch 04cc7e469d Implemented filesystem cache, one and only (see #1415) 2015-09-11 14:30:23 +02:00
Fabien Potencier 8af7659e3f updated CHANGELOG 2015-09-11 14:30:09 +02:00
Fabien Potencier 7cb4b945a4 feature #1813 Add $template->getSource() (nicolas-grekas)
This PR was merged into the 1.x branch.

Discussion
----------

Add $template->getSource()

Now that we have the source inlined, we should provide a way to get it. This also make it possible to feature-test if the source is available for backward/forward compat.

Commits
-------

de86850 Add $template->getSource()
2015-09-11 14:29:03 +02:00
Fabien Potencier 7e78fa584f fixed PHP 5.2 compt 2015-09-11 14:28:20 +02:00
Nicolas Grekas de86850bf7 Add $template->getSource() 2015-09-11 14:23:59 +02:00
Fabien Potencier 788870ec34 minor #1815 removed code that supports obsolete versions of PHP (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

removed code that supports obsolete versions of PHP

Commits
-------

33917e8 removed code that supports obsolete versions of PHP
2015-09-11 14:08:28 +02:00
Fabien Potencier 33917e87ae removed code that supports obsolete versions of PHP 2015-09-11 13:55:03 +02:00
Fabien Potencier 4ff8b3f002 minor #1809 Fix test (nicolas-grekas)
This PR was merged into the 1.x branch.

Discussion
----------

Fix test

Commits
-------

ff9afa0 Fix test
2015-09-10 11:13:50 +02:00
Nicolas Grekas ff9afa0dc3 Fix test 2015-09-10 11:07:58 +02:00
Fabien Potencier 37c006f7a7 fixed 5.2 compat 2015-09-10 10:57:20 +02:00
Fabien Potencier c7e9744ca8 feature #1807 Inline original source code in compiled templates (nicolas-grekas)
This PR was submitted for the master branch but it was merged into the 1.x branch instead (closes #1807).

Discussion
----------

Inline original source code in compiled templates

For introspection purposes (e.g. instead of https://github.com/symfony/symfony/pull/15653) it is sometimes useful to be able to retrieve the original template source code.

I propose to inline it commented after the compiled class declaration.
This creates no memory nor cpu overhead while still allowing to get the source with very simple parsing logic.

Commits
-------

c9fb373 Inline original source code in compiled templates
2015-09-10 10:50:56 +02:00
Nicolas Grekas c9fb3730c2 Inline original source code in compiled templates 2015-09-10 10:50:55 +02:00
Fabien Potencier 7d21eb9984 bumped version to 1.21.3-DEV 2015-09-09 07:33:05 +02:00
Fabien Potencier ddce1136be prepared the 1.21.2 release v1.21.2 2015-09-09 07:28:51 +02:00
Fabien Potencier 18854ff234 updated CHANGELOG 2015-09-09 07:23:01 +02:00
Fabien Potencier 825bdc1afc updated CHANGELOG 2015-09-06 08:45:56 +02:00
Fabien Potencier 542dd3acc0 feature #1795 Traversable support for 'replace', 'merge' and 'sort' (SpacePossum)
This PR was merged into the 1.x branch.

Discussion
----------

Traversable support for 'replace', 'merge' and 'sort'

Add traversable support to:
* replace
* merge
* sort

Other changes:
* Removes some not need checks
* ~~Make unit test skip if it cannot write to cache because of the user running the test~~
* Tests added for traversable support
* Doc updates

Deprecating:
I think the undocumented (and multibyte not supported) use of `replace(string, string)` can be removed in Twig 2.0.
Adding MB support and documentation of the feature was turned down (https://github.com/twigphp/Twig/pull/1618)
However removing it is a BC break (https://github.com/twigphp/Twig/pull/1445#issuecomment-48746926)

Commits
-------

2a17303 Mark test skipped if cannot write to cache directory.
2015-09-06 08:43:16 +02:00
Fabien Potencier b1a4c14b60 bug #1801 Fix variable names for the deprecation triggering code (stof)
This PR was merged into the 1.x branch.

Discussion
----------

Fix variable names for the deprecation triggering code

Closes https://github.com/twigphp/Twig/issues/1800

Commits
-------

dd446c0 Fix variable names for the deprecation triggering code
2015-09-01 11:38:14 +02:00
Christophe Coevoet dd446c0c65 Fix variable names for the deprecation triggering code 2015-09-01 11:30:25 +02:00
Fabien Potencier 0a19aab4a1 bug #1797 fix escaping strategy detection based on filename (Tobion)
This PR was merged into the 1.x branch.

Discussion
----------

fix escaping strategy detection based on filename

Fixes symfony/symfony#15095

It previously excluded any fileextension (not just `.twig`) which is pretty wrong.

Commits
-------

e403363 fix escaping strategy detection based on filename
2015-08-31 17:44:05 +02:00
Tobias Schultze e403363b1a fix escaping strategy detection based on filename 2015-08-31 14:50:02 +02:00
Possum 2a17303601 Mark test skipped if cannot write to cache directory.
Add Traversable support for replace, sort and merge filters.
2015-08-28 11:14:03 +02:00
Fabien Potencier 5815c8344b minor #1796 OPcache support fix (iKwinto)
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
2015-08-27 09:48:00 +02:00
Alexander Vasilyev 2c4af24b20 OPcache support fix 2015-08-27 09:47:21 +02:00