Commit Graph

3921 Commits

Author SHA1 Message Date
Fabien Potencier 70db030571 Merge branch '1.x' into 2.x
* 1.x:
  Fix GlobalsInterface extends for IDE
2018-07-25 15:16:50 +02:00
Fabien Potencier 7a3d825969 bug #2726 Fix GlobalsInterface extends for IDE (ogizanagi)
This PR was merged into the 1.x branch.

Discussion
----------

Fix GlobalsInterface extends for IDE

Commits
-------

0b819abb Fix GlobalsInterface extends for IDE
2018-07-25 15:16:22 +02:00
Maxime Steinhausser 0b819abb0d Fix GlobalsInterface extends for IDE 2018-07-25 15:11:25 +02:00
Fabien Potencier fda20a6336 Merge branch '1.x' into 2.x
* 1.x:
  updated CHANGELOG
  Do not throw error on validate or parse name if throw var is false
2018-07-20 15:30:21 +02:00
Fabien Potencier 03542492e9 updated CHANGELOG 2018-07-20 15:30:04 +02:00
Fabien Potencier 3491e3590e bug #2721 Don't throw error on validate or parse name if throw var is false (yceruto)
This PR was merged into the 1.x branch.

Discussion
----------

Don't throw error on validate or parse name if throw var is false

As spotted here https://github.com/symfony/symfony/issues/28001 `$loader->exists('@foo')` shouldn't throw an exception. e.g.: https://github.com/symfony/symfony/blob/9bfa971bc5662a6f90408b58a7b2453d7dae4f83/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php#L145

Commits
-------

a0e8d58a Do not throw error on validate or parse name if throw var is false
2018-07-20 15:28:02 +02:00
Yonel Ceruto a0e8d58a6e Do not throw error on validate or parse name if throw var is false 2018-07-20 08:04:00 -04:00
Fabien Potencier 60a8f465d6 bumped version to 2.5.1-DEV 2018-07-13 09:18:38 +02:00
Fabien Potencier 6a5f676b77 prepared the 2.5.0 release v2.5.0 2018-07-13 09:18:09 +02:00
Fabien Potencier bcf3f82fff updated CHANGELOG 2018-07-13 09:17:42 +02:00
Fabien Potencier cf392dae9b Merge branch '1.x' into 2.x
* 1.x:
  bumped version to 1.35.5-DEV
  prepared the 1.35.4 release
  updated CHANGELOG
2018-07-13 09:17:29 +02:00
Fabien Potencier cb848ee0a4 bumped version to 1.35.5-DEV 2018-07-13 09:13:09 +02:00
Fabien Potencier 7e081e9837 prepared the 1.35.4 release v1.35.4 2018-07-13 09:12:17 +02:00
Fabien Potencier c45939350b updated CHANGELOG 2018-07-13 09:11:45 +02:00
Fabien Potencier 84b2eb5410 Merge branch '1.x' into 2.x
* 1.x:
  Fix test
2018-06-25 17:02:58 +02:00
Fabien Potencier 76cc34554b minor #2714 Fix test (jderusse)
This PR was merged into the 1.x branch.

Discussion
----------

Fix test

Commits
-------

625ac797 Fix test
2018-06-25 17:02:19 +02:00
Jérémy Derussé 625ac79766 Fix test 2018-06-25 16:36:38 +02:00
Fabien Potencier f9e04df9d3 Merge branch '1.x' into 2.x
* 1.x:
  Use isset before array_key_exists
2018-06-25 15:41:36 +02:00
Fabien Potencier 0f45c2a677 minor #2710 Use isset before array_key_exists (jderusse)
This PR was merged into the 1.x branch.

Discussion
----------

Use isset before array_key_exists

Small performance improvment when using

```
{% set foo = foo|default("bar") %}
```
Will render the following code
```
$context["foo"] = (((isset($context["foo"]) || array_key_exists("foo", $context))) ? (_twig_default_filter((isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : (function () { throw new Twig_Error_Runtime('Variable "foo" does not exist.', 1, $this->source); })()), "bar")) : ("bar"));
```

instead of
```
$context["foo"] = ((array_key_exists("foo", $context)) ? (_twig_default_filter((isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : (function () { throw new Twig_Error_Runtime('Variable "foo" does not exist.', 1, $this->source); })()), "bar")) : ("bar"));
```

Commits
-------

230d3412 Use isset before array_key_exists
2018-06-25 15:41:18 +02:00
Jérémy Derussé 230d34128d Use isset before array_key_exists 2018-06-25 14:32:40 +02:00
Fabien Potencier 53ca200b96 bug #2702 Fix the error handling for the optimized extension-based function calls (stof)
This PR was merged into the 2.x branch.

Discussion
----------

Fix the error handling for the optimized extension-based function calls

Triggering a Twig_Error_Runtime at compile-time breaks the contract of the Twig environment, as such exception is for errors during the rendering.
This moves back the exception to a runtime one (same behavior than before the optimization).

Another option would be to replace this with a `Twig_Error_Syntax` instead (reporting the error earlier), but that would change the exception being thrown for such case.

Commits
-------

9928ae14 Fix the error handling for the optimized extension-based function calls
2018-06-07 07:44:00 +02:00
Fabien Potencier 4d18a63248 bug #2700 Report the proper location for errors compiled in templates (stof)
This PR was merged into the 2.x branch.

Discussion
----------

Report the proper location for errors compiled in templates

The `{% use %}` and `{% with %}` tags are adding some runtime checks triggering exceptions in the compiled template. This ensures that they get the proper location.
While the guessing was generally working fine for the `{% with %}` (and so this only makes the code faster), the guessing was not working for `{% use %}` due to the exception happening in the class constructor rather than on display (and so the guessing was finding the template which was triggering the load of the faulty template).

Commits
-------

e4423576 Report the proper location for errors compiled in templates
2018-06-07 07:42:53 +02:00
Fabien Potencier e3b8a34023 Merge branch '1.x' into 2.x
* 1.x:
  Ensure that syntax errors are triggered with the right line
  fix a typo
2018-06-07 07:41:23 +02:00
Fabien Potencier 3b71efb7b4 bug #2701 Ensure that syntax errors are triggered with the right line (stof)
This PR was merged into the 1.x branch.

Discussion
----------

Ensure that syntax errors are triggered with the right line

When throwing the syntax error without any line and source in these places, the guessing logic enters into action. For the main template, it won't find anything. But for included templates (or any other template loaded during the rendering of another one, even as main one), the guessing will find a template (the caller one) and set the source and line based on it. The source will then be replaced by the proper template by `\Twig_Environment::compileSource`, but the guessed line number will make no sense then.

I searched for all places triggering a syntax error in Twig, to ensure that they always set the actual line number or set the source directly (so that the guessing logic knows that the template it found is the wrong one and so does not try to use it for guessing). There were only a few missing ones.

Commits
-------

6fab6b0b Ensure that syntax errors are triggered with the right line
2018-06-07 07:40:46 +02:00
Christophe Coevoet e44235760b Report the proper location for errors compiled in templates
The {% use %} and {% with %} tags are adding some runtime checks triggering
exceptions in the compiled template. This ensures that they get the proper
location.
While the guessing was generally working fine for the {% with %} (and so this
only makes the code faster), the guessing was not working for {% use %} due
to the exception happening in the class constructor rather than on display
(and so the guessing was finding the template which was triggering the load
of the faulty template).
2018-06-06 22:58:46 +02:00
Christophe Coevoet 9928ae144b Fix the error handling for the optimized extension-based function calls
Triggering a Twig_Error_Runtime at compile-time breaks the contract of the
Twig environment, as such exception is for errors during the rendering.
2018-06-06 21:13:06 +02:00
Christophe Coevoet 6fab6b0bfa Ensure that syntax errors are triggered with the right line 2018-06-06 20:59:03 +02:00
Fabien Potencier b9c60342a3 minor #2695 fix a typo (xabbuh)
This PR was merged into the 1.x branch.

Discussion
----------

fix a typo

Commits
-------

36787f01 fix a typo
2018-05-31 07:46:32 +02:00
Christian Flothmann 36787f01d2 fix a typo 2018-05-30 21:54:04 +02:00
Fabien Potencier a97474976e feature #2685 Deprecate using the spaceless tag at the root level of a child template (noop anyway) (fabpot)
This PR was merged into the 2.x branch.

Discussion
----------

Deprecate using the spaceless tag at the root level of a child template (noop anyway)

~~WIP as I'd like to trigger a deprecation notice (which will only be possible with some other changes coming up in another PR) and add some tests for the deprecated behavior.~~

Commits
-------

b2dac7df deprecated using the spaceless tag at the root level of a child template (noop anyway)
2018-05-18 20:28:02 +02:00
Fabien Potencier b2dac7df50 deprecated using the spaceless tag at the root level of a child template (noop anyway) 2018-05-18 12:56:53 +02:00
Fabien Potencier 143e4f46f8 feature #2687 Deprecate the possibility to define a block in a non-capturing block from a child template (fabpot)
This PR was merged into the 2.x branch.

Discussion
----------

Deprecate the possibility to define a block in a non-capturing block from a child template

fixes #351, #541, #703, #988, #1639, #1685, #2393

One recurring issue (see the probably non-exhaustive list of issues references above) is a misunderstanding of how blocks work in a child template.

For instance, there is no way to define a `block` conditionally:

```twig
{% extends "layout" %}

{% if ... %}
    {% block content %}
        ...
    {% endblock %}
{% endif %}
```

And wrapping a `block` definition with a `spaceless` tag does not work:

```twig
{% extends "layout" %}

{% spaceless %}
    {% block content %}
        ...
    {% endblock %}
{% endspaceless %}
```

The issue is that the above templates compile just fine, but not in a way people expect. Basically, the condition would be empty.

Interestingly enough, wrapping a `block` definition might be useful/work as expected when used with "capturing" tags like `set`:

```twig
{% extends "layout" %}

{% set content %}
    {% block content %}
        ...
    {% endblock %}
{% endset %}
```

Not sure if that's useful, but here, the `block` tag will serve as the blog definition AND it will also be displayed in place. I would not recommend such usages.

This pull request deprecates the cases where the compiled template would never reflect the developer intent, but keeps the "working" scenarii as is.

I've been trying to fix that issue for **years**. Very happy to have found a simple solution without breaking anything that worked fine.

Commits
-------

9b938887 deprecated the possibility to define a block in a non-capturing block from a child template
2018-05-18 12:15:51 +02:00
Fabien Potencier 9b9388878a deprecated the possibility to define a block in a non-capturing block from a child template 2018-05-18 11:59:40 +02:00
Fabien Potencier 83601c5728 minor #2686 Move legacy tests that were not executed anymore in 2.x (fabpot)
This PR was merged into the 2.x branch.

Discussion
----------

Move legacy tests that were not executed anymore in 2.x

While working on some new deprecations, I noticed that some fixtures were in a directory that was not used anymore in 2.x. I've moved the relevant one back to the main Fixtures directory and remove the other one, which is not relevant anymore.

Commits
-------

c412d0f4 moved legacy tests that were not executed anymore in 2.x
2018-05-18 10:47:04 +02:00
Fabien Potencier c412d0f405 moved legacy tests that were not executed anymore in 2.x 2018-05-18 09:55:44 +02:00
Fabien Potencier b23e42fd83 Merge branch '1.x' into 2.x
* 1.x:
  fixed typo
2018-05-18 09:45:53 +02:00
Fabien Potencier b705a3a028 fixed typo 2018-05-18 09:45:47 +02:00
Fabien Potencier 44bb6cc9ac bumped version to 2.5.0 2018-05-18 09:34:00 +02:00
Fabien Potencier e83a58a517 updated CHANGELOG 2018-05-18 09:25:42 +02:00
Fabien Potencier eff4f9f622 Merge branch '1.x' into 2.x
* 1.x:
  fixed doc markup
  Fixed PHPDoc of Twig_Token::test
  added the Symfony ctype polyfill as a dependency
  Added missing edge-cases
2018-05-18 09:25:34 +02:00
Fabien Potencier f4c020923f fixed doc markup 2018-05-18 09:23:18 +02:00
Fabien Potencier f9638a0d14 fixed doc markup 2018-05-18 09:22:42 +02:00
Fabien Potencier 5f18e99163 minor #2678 Added missing edge-cases (ismael-miguel)
This PR was merged into the 1.x branch.

Discussion
----------

Added missing edge-cases

Discussion on: https://github.com/twigphp/Twig/issues/2677

Commits
-------

22739e7d Added missing edge-cases
2018-05-12 11:39:44 +02:00
Fabien Potencier ed02b30a17 minor #2681 Fixed PHPDoc of Twig_Token::test (lyrixx)
This PR was merged into the 1.x branch.

Discussion
----------

Fixed PHPDoc of Twig_Token::test

For exemple `Twig_TokenParser_Set` use `->test('endset')`

Commits
-------

35a1070a Fixed PHPDoc of Twig_Token::test
2018-05-02 17:04:18 +02:00
Grégoire Pineau 35a1070a62 Fixed PHPDoc of Twig_Token::test
For exemple Twig_TokenParser_Set use ->test('endset')
2018-05-02 16:04:55 +02:00
Fabien Potencier 257d0656cc minor #2680 Add the Symfony ctype polyfill as a dependency (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Add the Symfony ctype polyfill as a dependency

Commits
-------

5b9a70b3 added the Symfony ctype polyfill as a dependency
2018-05-02 07:48:32 +02:00
Fabien Potencier 5b9a70b3a3 added the Symfony ctype polyfill as a dependency 2018-05-01 21:12:10 +02:00
ismael-miguel 22739e7d13 Added missing edge-cases
Discussion on: https://github.com/twigphp/Twig/issues/2677
2018-04-25 20:48:23 +01:00
Fabien Potencier 055dea2c6d use HTTPS whenever possible 2018-04-20 08:10:29 +02:00
Fabien Potencier 07e0ed7f06 removed extra whitespaces 2018-04-20 08:09:57 +02:00