Commit Graph

7732 Commits

Author SHA1 Message Date
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
Fabien Potencier 3546a36137 minor #1819 [Twig 2] make datetime handling according to minimum php version (Tobion)
This PR was merged into the 2.0-dev branch.

Discussion
----------

[Twig 2] make datetime handling according to minimum php version

- phpdoc for DateTimeInterface is enough
- remove obsolete stuff

Commits
-------

6bb7d45 make datetime handling according to minimum php version
2015-09-12 10:51:11 +02:00
Tobias Schultze 163f42ea5c no need to call setTimezone on a current date 2015-09-11 21:40:19 +02:00
Tobias Schultze 6bb7d45c02 make datetime handling according to minimum php version 2015-09-11 20:54:06 +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 69774e27ea Merge branch '1.x'
* 1.x:
  Fix inlining of sources with CRLF
  fixed deprecation docs
  fixed CHANGELOG
2015-09-11 18:09:36 +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 7171df4294 removed deprecated features 2015-09-11 16:48:29 +02:00
Fabien Potencier 620de79223 Merge branch '1.x'
* 1.x:
  added a cache interface for templates
  Implemented filesystem cache, one and only (see #1415)
  updated CHANGELOG
  fixed PHP 5.2 compt
  Add $template->getSource()
  removed code that supports obsolete versions of PHP
  Fix test
  fixed 5.2 compat
  Inline original source code in compiled templates
2015-09-11 16:43:01 +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 d979bdffa5 Merge branch '1.x'
* 1.x:
  bumped version to 1.21.3-DEV
  prepared the 1.21.2 release
  updated CHANGELOG
2015-09-09 08:02:33 +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 6c107c513a fixed typo 2015-09-06 08:50:29 +02:00
Fabien Potencier 12fb6f88a1 removed versionadded tags in docs 2015-09-06 08:49:46 +02:00
Fabien Potencier 05340fe52c removed deprecated feature 2015-09-06 08:48:24 +02:00
Fabien Potencier c3d92b2cc7 Merge branch '1.x'
* 1.x:
  updated CHANGELOG
  Fix variable names for the deprecation triggering code
  Mark test skipped if cannot write to cache directory.
2015-09-06 08:47:52 +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 90c9bc31d2 readded code lost in master 2015-09-01 07:59:31 +02:00
Fabien Potencier 3abc195e5f Merge branch '1.x'
* 1.x:
  fix escaping strategy detection based on filename
  OPcache support fix
2015-09-01 07:51:16 +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