Commit Graph

3376 Commits

Author SHA1 Message Date
Fabien Potencier 4f57c6eab8 use HTTPS whenever possible 2018-04-20 08:05:14 +02:00
Fabien Potencier 28690681d1 fixed website URL 2018-04-20 07:23:43 +02:00
Fabien Potencier d11c1f1a69 minor #2670 Fix partial template caching after update when auto_reload is on (ay-git)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2670).

Discussion
----------

Fix partial template caching after update when auto_reload is on

**Description of the bug:**
This bug manifests itself on production servers.
And with a high load the probability of getting on this bug tends to 100%
The bug results in the caching of a partial template and the failure of a part of the site working with this template. Can only be corrected by deleting the cache.

**What's happening:**
If in the process of uploading the template file, a render() is called, the partially uploaded file gets into the cache and after the template file is fully uploaded, the cache is not updated anymore.

**How to demonstrate:**
To demonstrate the bug, you can create 2 files:
File simulating the download of a file to the server (twig_test_write.php):

```
$classTwig = new Twig_Environment( new Twig_Loader_Filesystem(__DIR__."/../../site_templates/"), array(
	'cache' => __DIR__.'/../../site_templates_cache',
	'auto_reload'=>true
));

file_put_contents(__DIR__."/../../site_templates/"."test.twig","\n<br>Template start write to filesystem");

echo $classTwig->render("test.twig", array());

file_put_contents(__DIR__."/../../site_templates/"."test.twig"," - Template end write to filesystem",FILE_APPEND);

```

File for template rendering (twig_test_read.php):
```
$classTwig = new Twig_Environment( new Twig_Loader_Filesystem(__DIR__."/../../site_templates/"), array(
	'cache' => __DIR__.'/../../site_templates_cache',
	'auto_reload'=>true
));

echo $classTwig->render("test.twig", array());
```

Result executeing file twig_test_write.php:
```
Template start write to filesystem
```

Result executeing file twig_test_read.php:
```
Template start write to filesystem
```

**After this fix:**
Result executeing file twig_test_read.php:
```
Template start write to filesystem - Template end write to filesystem
```

Commits
-------

50d990e2 Fix cache update after uploading the template file (when auto-update is enabled).
2018-04-19 10:56:23 +02:00
AY_W 50d990e23d Fix cache update after uploading the template file (when auto-update is enabled).
If in the process of uploading the template file, a render() is called, the partially uploaded file gets into the cache and after the template file is fully uploaded, the cache is not updated anymore.
2018-04-19 10:56:18 +02:00
Fabien Potencier 3bc9686dc5 minor #2668 Small optimization for Twig_NodeTraverser::traverseForVisitor (covex-nn)
This PR was merged into the 1.x branch.

Discussion
----------

Small optimization for Twig_NodeTraverser::traverseForVisitor

During traversing a node tree `Twig_NodeTraverser::traverseForVisitor` (`Twig_NodeVisitorInterface::leaveNode`) often returns a same child node (a same object). So, there is no need to set it back to its parent.

This PR adds a check if a child node was changed. With this check a lot of calls to `Twig_Node::setNode` will be skipped.

Closes #2665

Commits
-------

555d01f3 Small optimization for Twig_NodeTraverser::traverseForVisitor
2018-04-01 20:24:34 +02:00
Andrey F. Mindubaev 555d01f327 Small optimization for Twig_NodeTraverser::traverseForVisitor 2018-03-26 09:53:48 +03:00
Fabien Potencier ce4aff66cc bug #2581 Add JSON escape strategy (c960657)
This PR was squashed before being merged into the 1.x branch (closes #2581).

Discussion
----------

Add JSON escape strategy

The `js` escape strategy used `\xNN`-style escape sequences. This is not allowed in JSON, only `\uNNNN` is allowed.

This PR adds a new escape strategy, `json` that is similar to `js` except that it does not use `\xNN` but uses `\uNNNN` instead.

I know that I can use `json_decode()`, but it came as a surprise to me that `escape('js')` did not work. You probably shouldn't be generating JSON structures in your templates, but sometimes it comes in handy. My use-case was generating a piece of [JSON-LD](https://json-ld.org).

A different approach that would perhaps be less confusing to users would be to change `js` to not use `\xNN`. This output is still valid JavaScript, it just uses two more bytes per occurrence. Let me know what you think.

Commits
-------

5c7b080b Add JSON escape strategy
2018-03-25 10:27:49 +02:00
Christian Schmidt 5c7b080b31 Add JSON escape strategy 2018-03-25 10:27:41 +02:00
Fabien Potencier c35ad8c4e3 bumped version to 1.35.4-DEV 2018-03-20 05:26:35 +01:00
Fabien Potencier b48680b6eb prepared the 1.35.3 release v1.35.3 2018-03-20 05:25:58 +01:00
Fabien Potencier dc53726ff0 updated CHANGELOG 2018-03-20 05:25:36 +01:00
Fabien Potencier 4b14c38ad5 bug #2664 Fix block names unicity (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Fix block names unicity

closes #2658

Commits
-------

6da72c6d fixed block names unicity
2018-03-20 05:05:35 +01:00
Fabien Potencier 6da72c6d8c fixed block names unicity 2018-03-20 04:57:51 +01:00
Fabien Potencier 3ff78ec072 minor #2663 Remove dev deps in composer.json (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Remove dev deps in composer.json

Commits
-------

64349bcf removed dev deps in composer.json
2018-03-19 18:22:57 +01:00
Fabien Potencier 64349bcf49 removed dev deps in composer.json 2018-03-19 18:18:16 +01:00
Fabien Potencier 4d9dc79516 bug #2659 [v1] Fixed counting children of SimpleXMLElement object (webimpress)
This PR was merged into the 1.x branch.

Discussion
----------

[v1] Fixed counting children of SimpleXMLElement object

It works correctly in v1.32 and since v1.33 it is not working correctly.
See: https://github.com/twigphp/Twig/compare/v1.32.0...v1.33.0#diff-d7378002f67a61c458c1de0468eef74fR1265

Test code:
```php
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><doc><elem/><elem/></doc>');

var_dump($xml instanceof \Countable);
echo 'Count: ' . count($xml), PHP_EOL;
echo 'Strlen: ' . strlen($xml), PHP_EOL;
echo 'MB Strlen: ' . mb_strlen($xml), PHP_EOL;
```

Results:
```
bool(false)
Count: 2
Strlen: 0
MB Strlen: 0
```

https://3v4l.org/VvUXG

Commits
-------

4a23bdc3 Fixed counting children of SimpleXMLElement object
2018-03-14 08:27:12 -07:00
webimpress 4a23bdc345 Fixed counting children of SimpleXMLElement object 2018-03-14 10:16:52 +00:00
Fabien Potencier 981c4d8ca0 bug #2652 Add missing else clause to avoid infinite loops (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Add missing else clause to avoid infinite loops

Commits
-------

de2be6a0 added missing else clause to avoid infinite loops
2018-03-04 18:08:10 -08:00
Fabien Potencier de2be6a0ee added missing else clause to avoid infinite loops 2018-03-04 18:07:35 -08:00
Fabien Potencier ab6c99e707 bug #2651 Fix .. (range operator) in sandbox policy (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Fix .. (range operator) in sandbox policy

Closes #2630

Commits
-------

6f45fcf5 fixed .. (range operator) in sandbox policy
2018-03-04 17:57:12 -08:00
Fabien Potencier 6f45fcf519 fixed .. (range operator) in sandbox policy 2018-03-04 10:12:13 -08:00
Fabien Potencier bf7bbf1e93 fixed version 2018-03-03 08:24:39 -08:00
Fabien Potencier fe4a5e846c bumped version to 1.35.3-DEV 2018-03-03 08:22:00 -08:00
Fabien Potencier 9c24f2cd39 prepared the 1.35.2 release v1.35.2 2018-03-03 08:21:29 -08:00
Fabien Potencier 1278ca96af bug #2647 Fix profiler unicity when several ones are registered (fabpot)
This PR was squashed before being merged into the 1.x branch (closes #2647).

Discussion
----------

Fix profiler unicity when several ones are registered

Closes #2627, closes #2643, alternative to #2645

What happens is that both Twig and Symfony register a Twig profiler. Unfortunately, the current code does assign the same variable for both profiler, which means that trying to close it twice does not work.

Commits
-------

0ee096f0 fixed test
7b2bdbe3 fixed profiler unicity when several ones are registered
2018-03-03 08:18:26 -08:00
Fabien Potencier 0ee096f092 fixed test 2018-03-03 07:53:48 -08:00
Fabien Potencier 7b2bdbe351 fixed profiler unicity when several ones are registered 2018-03-03 07:49:53 -08:00
Fabien Potencier caf2caa8f4 fixed CS 2018-03-02 13:09:41 -08:00
Fabien Potencier b047676503 minor #2639 Switch the PHP ext jobs to a whitelist rather than a blacklist (stof)
This PR was merged into the 1.x branch.

Discussion
----------

Switch the PHP ext jobs to a whitelist rather than a blacklist

Any new PHP version added in the future will be a PHP 7.x one, not a 5.x one, and so should not have a job for the extension.

the whitelist is already shorter than the blacklist today (3 whitelisted vs 4 blacklisted before, as PHP 5.3 is already handled separately due to precise anyway)

Commits
-------

738f17bb Switch the PHP ext jobs to a whitelist rather than a blacklist
2018-03-02 13:05:33 -08:00
Christophe Coevoet 738f17bb45 Switch the PHP ext jobs to a whitelist rather than a blacklist
Any new PHP version added in the future will be a PHP 7.x one, not a 5.x one, and so should not have a job for the extension.
2018-03-02 19:08:25 +01:00
Fabien Potencier 067ade15e6 bumped version to 1.35.2-DEV 2018-03-02 10:07:31 -08:00
Fabien Potencier ffda54d85c prepared the 1.35.1 release v1.35.1 2018-03-02 10:06:27 -08:00
Fabien Potencier 277b400158 bug #2637 Fix C ext (fabpot)
This PR was squashed before being merged into the 1.x branch (closes #2637).

Discussion
----------

Fix C ext

Commits
-------

bffc117f simplified code
a0c24242 fixed C ext
64e85689 fixed Travis config
2018-03-02 10:04:32 -08:00
Fabien Potencier bffc117f53 simplified code 2018-03-02 09:54:18 -08:00
Fabien Potencier a0c24242de fixed C ext 2018-03-02 09:53:02 -08:00
Fabien Potencier 64e856892b fixed Travis config 2018-03-02 09:53:02 -08:00
Fabien Potencier bf34cadf0f updated CHANGELOG 2018-03-02 08:56:04 -08:00
Fabien Potencier 1445246d8e added missing test 2018-03-02 06:04:04 -08:00
Fabien Potencier 9e7db77331 bug #2411 Exception for use of "===" instead of "same as" (sgotre)
This PR was squashed before being merged into the 1.x branch (closes #2411).

Discussion
----------

Exception for use of "===" instead of "same as"

As mentioned in #2358
Hope this is the right location for this Exception

Commits
-------

194d51a4 Exception for use of "===" instead of "same as"
2018-03-02 06:02:21 -08:00
sgotre 194d51a4a8 Exception for use of "===" instead of "same as" 2018-03-02 06:02:16 -08:00
Fabien Potencier e8555dc8ee minor #2633 Update .travis.yml to test on PHP 7.2 (gmponos)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2633).

Discussion
----------

Update .travis.yml to test on PHP 7.2

Commits
-------

8e7527ec Update .travis.yml
2018-02-28 08:23:15 -08:00
Mponos George 8e7527ec97 Update .travis.yml 2018-02-28 08:23:05 -08:00
Fabien Potencier 8a7fba9560 bug #2624 Fix possible array to string conversion concealing actual error (finwe)
This PR was merged into the 1.x branch.

Discussion
----------

Fix possible array to string conversion concealing actual error

This is a 1.x branch backport of #2613

Commits
-------

7ba3b5a5 Fix possible array to string conversion concealing actual error
2018-02-07 20:24:52 +01:00
Fabien Potencier f2e5f4080c bug #2621 Make variable names deterministic (lstrojny)
This PR was merged into the 1.x branch.

Discussion
----------

Make variable names deterministic

Variables should be deterministic to support reproducible builds as outlined in https://github.com/symfony/symfony/issues/25958

Commits
-------

6ab5fe9b Make variable names deterministic
2018-02-07 20:22:14 +01:00
Matěj Humpál 7ba3b5a589 Fix possible array to string conversion concealing actual error 2018-02-07 15:47:38 +01:00
Lars Strojny 6ab5fe9b8f Make variable names deterministic 2018-01-31 18:04:41 +01:00
Fabien Potencier e923101942 bug #2600 Be able to count on iterator (scuben)
This PR was merged into the 1.x branch.

Discussion
----------

Be able to count on iterator

This PR allows to count on `\Traversable` Objects. Not sure if I made the change to the correct branch. Tell me please if I should target 2.x or master.

Commits
-------

be2c32cc Be able to count on iterator
2018-01-30 17:11:48 +01:00
ARTACK WebLab be2c32cc1c Be able to count on iterator 2018-01-30 17:04:01 +01:00
Fabien Potencier f93530b440 made it clear that placeholders are free-forms for the replace filter 2018-01-30 08:01:42 +01:00
Fabien Potencier 1040696c52 minor #2612 English tweak contents -> content (weaverryan)
This PR was merged into the 1.x branch.

Discussion
----------

English tweak contents -> content

The most minor PR ever :).

Made to the 1.x branch, also applies to 2.x obviously.

Commits
-------

19e3fb8c contents -> content
2018-01-30 07:52:44 +01:00