Commit Graph

3205 Commits

Author SHA1 Message Date
Fabien Potencier f8d4c096ae feature #2420 Make "length" filter and "empty" test consider __toString [Twig 1.x] (mpdude)
This PR was squashed before being merged into the 1.x branch (closes #2420).

Discussion
----------

Make "length" filter and "empty" test consider __toString [Twig 1.x]

Use case: When you have variables in your views that are actually objects but implement `__toString`, they feel like strings: For example, `{{ something }}` will make use of that to-string-conversion.

What does *not* work is

**a)** `{{ something | length }}`, because that will only have a meaningful return value for objects implementing `\Countable`. This interface, however, may have a totally different semantic/purpose for the object in question.

**b)** `{% if something is empty %}`, because

> empty checks if a variable is an empty string, an empty array, an empty hash, exactly false, or exactly null  `[http://twig.sensiolabs.org/doc/2.x/tests/empty.html]`

... and obviously `something !== null` in this case.

For template designers, this may be surprising if they don't actually care about the object-or-string difference, they just "use" the variable.

This change tries to address this as it changes the behavior for  such objects that have a `__toString` method and are *not* `\Countable`.

*Yes*, it's a BC break in edge cases:

For a), objects that implement a `__toString` but not `\Countable` would previously yield `1` for `{{ object | length }}`, and now would return the length of the string returned by `__toString`.

For b), testing (defined) variables that are objects implementing  `__toString` and that return `''`,  the test now is `false`.

Commits
-------

f5193e92 Make "length" filter and "empty" test consider __toString [Twig 1.x]
2017-03-22 07:45:54 -07:00
Matthias Pigulla f5193e92c5 Make "length" filter and "empty" test consider __toString [Twig 1.x] 2017-03-22 07:33:03 -07:00
Fabien Potencier 98f0d2b128 minor #2429 fixed risky tests (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

fixed risky tests

Commits
-------

7259e52f fixed risky tests
2017-03-20 08:49:31 -07:00
Fabien Potencier 7259e52fa4 fixed risky tests 2017-03-20 08:35:32 -07:00
Fabien Potencier ae2d59da05 bug #2427 Fixed JS escaping for unicode characters with higher code points (mikealmond)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2427).

Discussion
----------

Fixed JS escaping for unicode characters with higher code points

Unicode characters with higher code points were being escaped incorrectly. When these characters are escaped, they should maintain their surrogate halves. Previously, Twig was dropping the first surrogate half.

https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point
> The tetragram for centre symbol (𝌆) has code point U+1D306, so you could write it as \u{1D306}. For comparison, if you were to use simple Unicode escapes to represent this symbol, you’d have to write out the surrogate halves separately: '\uD834\uDF06'.

Commits
-------

7f913495 Fixed JS escaping for unicode characters with higher code points
2017-03-17 10:19:15 -07:00
Mike Almond 7f9134952d Fixed JS escaping for unicode characters with higher code points 2017-03-17 10:19:06 -07:00
Fabien Potencier c5ba65ca44 minor #2422 Updated the vim-twig link (InFog)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2422).

Discussion
----------

Updated the vim-twig link

The other project is not maintained anymore and the author recommends this fork.

Commits
-------

955d5abd Updated the vim-twig link
2017-03-12 08:19:55 -07:00
Evaldo Junior 955d5abd92 Updated the vim-twig link
The other project is not maintained anymore and the author recommends this fork.
2017-03-12 08:19:54 -07:00
Fabien Potencier 3fddfd41d0 minor #2423 PHPUnit 6 compatability (xabbuh)
This PR was merged into the 1.x branch.

Discussion
----------

PHPUnit 6 compatability

This should make builds on Traivs CI green again.

Commits
-------

0d791de6 PHPUnit 6 compatability
2017-03-12 08:17:33 -07:00
Christian Flothmann 0d791de63d PHPUnit 6 compatability 2017-03-11 20:03:13 +01:00
Fabien Potencier efb110d3d0 minor #2421 Fix codeblock in recipes documentation (aaa2000)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2421).

Discussion
----------

Fix codeblock in recipes documentation

Commits
-------

adba4c2a Fix codeblock
2017-03-10 08:51:30 -08:00
aaa2000 adba4c2a2b Fix codeblock 2017-03-10 08:51:30 -08:00
Fabien Potencier 4b2e9ef2a7 bug #2417 Compiler - setlocale must be a string (SpacePossum)
This PR was merged into the 1.x branch.

Discussion
----------

Compiler - setlocale must be a string

Following the docs of [setlocale](http://php.net/manual/en/function.setlocale.php) the second argument must be a `string`, `null` or an `array`. Special note about "0" is there as well.

closes https://github.com/twigphp/Twig/issues/2416

Commits
-------

9de41cfe Update Compiler.php
2017-03-08 09:45:58 -08:00
SpacePossum 9de41cfed9 Update Compiler.php 2017-03-08 18:10:11 +01:00
Fabien Potencier 27d7ea9675 bumped version to 1.32.1-DEV 2017-02-26 16:07:56 -08:00
Fabien Potencier 9935b662e2 prepared the 1.32.0 release v1.32.0 2017-02-26 16:07:03 -08:00
Fabien Potencier 48e17f7c63 udpated CHANGELOG 2017-02-26 15:19:41 -08:00
Fabien Potencier b0ec8390f8 improved some tests 2017-02-23 06:58:09 -08:00
Fabien Potencier 8ff73ca55b removed trailing space 2017-02-23 06:56:46 -08:00
Fabien Potencier af0d787c43 fixed CS 2017-02-23 06:54:27 -08:00
Fabien Potencier c84a511f52 feature #2403 #1802 left/right trim (antonydandrea)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2403).

Discussion
----------

#1802 left/right trim

It was said in this thread that there was a preference of adding parameters to the trim filter in order to implement this.

So this feature works like:

trim(character_mask, mode), where mode is either "both", "left" or "right". It is by default "both".

This is my first pull request of this project, so I apologise in advance if something is wrong.

Commits
-------

7d8e7550 #1802 left/right trim
2017-02-23 06:52:12 -08:00
Antony D'Andrea 7d8e75504c #1802 left/right trim 2017-02-23 06:52:03 -08:00
Fabien Potencier 30085c5e78 bug #2407 added some missing tests (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

added some missing tests

Commits
-------

236c1bdc added some missing tests
2017-02-21 18:52:36 -08:00
Fabien Potencier 236c1bdc32 added some missing tests 2017-02-21 18:49:28 -08:00
Fabien Potencier bb3f4d6183 bug #2406 Fix tokenize call in DeprecationCollector (vdechenaux)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2406).

Discussion
----------

Fix tokenize call in DeprecationCollector

Hi,

if fixes `Argument 1 passed to Twig_Environment::tokenize() must be an instance of Twig_Source, string given`

Commits
-------

13ca97c1 Fix tokenize call in DeprecationCollector
2017-02-21 07:46:47 -08:00
Vincent Dechenaux 13ca97c16f Fix tokenize call in DeprecationCollector 2017-02-21 07:46:38 -08:00
Fabien Potencier b6a16a21f9 fixed tests for PHP 5.2 2017-02-17 11:29:51 -08:00
Fabien Potencier 7f9928d85c minor #2402 Fix typo in test filename (chalasr)
This PR was merged into the 1.x branch.

Discussion
----------

Fix typo in test filename

Commits
-------

e5860f1f Fix typo in test filename
2017-02-17 11:27:19 -08:00
Fabien Potencier f63c6e1a9a fixed tests for PHP 5.2 2017-02-17 11:26:43 -08:00
Fabien Potencier ef2a7d7c36 fixed tests for PHP 5.2 2017-02-17 11:23:47 -08:00
Robin Chalas e5860f1fac Fix typo in test filename 2017-02-17 20:19:55 +01:00
Fabien Potencier 7efe539b82 added a note in the docs about the PSR-11 runtime loader 2017-02-17 11:16:50 -08:00
Fabien Potencier c9ce259c9f fixed typo 2017-02-17 11:15:01 -08:00
Fabien Potencier 056689f719 updated CHANGELOG 2017-02-17 11:14:29 -08:00
Fabien Potencier d2863a89c8 feature #2401 Add ContainerRuntimeLoader (chalasr)
This PR was merged into the 1.x branch.

Discussion
----------

Add ContainerRuntimeLoader

Next to https://github.com/symfony/symfony/pull/21625#discussion_r101715445

Commits
-------

964a51bc Add ContainerRuntimeLoader
2017-02-17 11:12:59 -08:00
Fabien Potencier f08c06ed7e bumped version to 1.32 2017-02-17 11:10:54 -08:00
Robin Chalas 964a51bc02 Add ContainerRuntimeLoader 2017-02-17 19:29:40 +01:00
Fabien Potencier d6715ac8c3 tweaked docs 2017-02-03 13:34:15 -08:00
Fabien Potencier 86f9e9a6d0 minor #2371 Update striptags.rst (peter17)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2371).

Discussion
----------

Update striptags.rst

Add information about supported param. Replaces #2370

Commits
-------

048f5490 Update striptags.rst
2017-02-03 13:32:21 -08:00
Peter Potrowl 048f549017 Update striptags.rst 2017-02-03 13:32:21 -08:00
Fabien Potencier 73de309fb4 fixed CS 2017-02-03 13:30:43 -08:00
Fabien Potencier e675c08a90 minor #2388 Mention autoescape=true deprecation (issue #2386) (vphantom)
This PR was squashed before being merged into the 1.x branch (closes #2388).

Discussion
----------

Mention autoescape=true deprecation (issue #2386)

Per #2386, mention the deprecation of true in favor of an explicit "html".

Commits
-------

70d03042 Mention autoescape=true deprecation (issue #2386)
2017-02-03 13:29:56 -08:00
Stéphane Lavergne 70d03042df Mention autoescape=true deprecation (issue #2386) 2017-02-03 13:29:55 -08:00
Fabien Potencier a1c1f01eac minor #2368 Fix typo in annotation of utest. (SpacePossum)
This PR was merged into the 1.x branch.

Discussion
----------

Fix typo in annotation of utest.

Commits
-------

61d31c8f Fix typo.
2017-01-19 06:55:10 -08:00
SpacePossum 61d31c8fef Fix typo. 2017-01-19 14:08:47 +01:00
Fabien Potencier 9b3796b140 bumped version to 1.31.1-DEV 2017-01-11 11:37:33 -08:00
Fabien Potencier ddc9e3e20e prepared the 1.31.0 release v1.31.0 2017-01-11 11:36:15 -08:00
Fabien Potencier c9a14464a3 added a note about macros usage in the deprecated docs 2017-01-11 11:20:42 -08:00
Fabien Potencier feb9bf539f bug #2354 Turned fatal error into exception when a previously generated cache prevents loading its newly compiled version (nicolas-grekas)
This PR was merged into the 1.x branch.

Discussion
----------

Turned fatal error into exception when a previously generated cache prevents loading its newly compiled version

Not sure if this is testable, yet this should save some hours to people that end up in the same trap we did on our project.
It turned out we generated some twig template cache in two separate commands, in a situation where "index" tracking for embeds where lost.

This PR detects the situation and invites to clear the cache properly, because that's the only way to fix the issue.

It also fixes a mistake in the cache $key generation, that should not take $index into account.
Doing so were making offline cache warmup useless in some situations.

Commits
-------

95c10991 Turned fatal error into exception when a previously generated cache prevents loading its newly compiled version
2017-01-11 08:01:13 -08:00
Nicolas Grekas 95c109919a Turned fatal error into exception when a previously generated cache prevents loading its newly compiled version 2017-01-11 16:22:32 +01:00