Commit Graph

1281 Commits

Author SHA1 Message Date
Fabien Potencier 1bfeed24c2 merged branch webwizard/patch-1 (PR #628)
Commits
-------

904dfef fixed typo

Discussion
----------

fixed typo
2012-02-12 20:28:11 +01:00
Victor Zamfir 904dfefb0b fixed typo 2012-02-12 21:10:01 +02:00
Fabien Potencier 4478816e41 removed usage of assertInstanceOf as if is not available when using PHPUnit on PHP 5.2.* 2012-02-06 18:16:12 +01:00
Fabien Potencier 5dd0aaec16 added more safeguards in unit tests to support different configuraitons 2012-02-06 16:21:45 +01:00
Fabien Potencier 2bcd60c9a8 updated CHANGELOG 2012-02-06 10:05:54 +01:00
Fabien Potencier 3561a45c85 added some unit tests for previous merge 2012-02-06 10:03:50 +01:00
Fabien Potencier 0150fdf8db fixes CS 2012-02-06 10:01:07 +01:00
Fabien Potencier 41927410d9 merged branch sv1l/master (PR #623)
Commits
-------

b6007f1 Fixed slice filter w/ null length for string values

Discussion
----------

Fixed issue #622: strings slice filter w/ no length

Fixed issue [#622](https://github.com/fabpot/Twig/issues/622)
2012-02-06 09:58:24 +01:00
Sylvain Dethier b6007f1cd5 Fixed slice filter w/ null length for string values 2012-02-05 18:37:26 +01:00
Fabien Potencier 5b5de2c743 fixed the creation of the cache directory in case of a race condition (closes #620) 2012-02-04 09:40:09 +01:00
Fabien Potencier 203945602b bumped version to 1.7.0-DEV 2012-02-04 08:38:29 +01:00
Fabien Potencier 9154d27622 prepared the 1.6.0 release v1.6.0 2012-02-04 08:34:52 +01:00
Fabien Potencier 8256bfa05c added missing entry in the doc 2012-01-31 11:57:59 +01:00
Fabien Potencier 310020ac98 fixed raw blocks when used with the whitespace trim option (closes #617) 2012-01-28 17:45:54 +01:00
Fabien Potencier 0eadacf6ba added some unit tests for the reverse filter when charset is not UTF-8 2012-01-28 17:12:21 +01:00
Fabien Potencier 12042e0880 added some unit tests for random() when charset is not UTF-8 2012-01-28 17:09:25 +01:00
Fabien Potencier 36d392b0de fixed previous commit 2012-01-28 16:58:52 +01:00
Fabien Potencier bc80f48f6a fixed the random() function on strings when the charset is not UTF-8
(refs #614)
2012-01-27 08:25:05 +01:00
Fabien Potencier bf61cc5344 fixed CS 2012-01-26 15:06:15 +01:00
Fabien Potencier 3bec772bea merged branch Tobion/test-coverage (PR #615)
Commits
-------

814cefd improve test coverage and support negative int for random function

Discussion
----------

improve test coverage and support negative int for random function
2012-01-26 15:06:02 +01:00
Tobias Schultze 814cefdad7 improve test coverage and support negative int for random function 2012-01-26 14:52:41 +01:00
Fabien Potencier cbadac91cd tweaked doc 2012-01-26 13:25:31 +01:00
Fabien Potencier 197a3115c7 merged branch Tobion/patch-4 (PR #614)
Commits
-------

a15e8f7 typo again
2561aa2 typo
faa90c9 updated doc for random function
fe66358 added tests for random function
6f5ceee Made the random function more versatile

Discussion
----------

Made the random function more versatile

The point is to meet user expectations and to make it more versatile, so it works under more circumstances.
At the moment the random function does only return the supplied parameter when it's not an array. That is not very useful. With this PR it will behave like

    random() => integer as with mt_rand()
    random(5) => integer between 0 and 5 as with mt_rand(0, 5)
    random('foobar') => random character from 'foobar'
    random(array(...)) => random element

I will add tests and documentation if you accept this PR.

---------------------------------------------------------------------------

by fabpot at 2012-01-26T07:29:35Z

Looks good to me. Can you update the docs and add some unit tests?

---------------------------------------------------------------------------

by Tobion at 2012-01-26T11:50:17Z

ready
2012-01-26 13:24:26 +01:00
Tobias Schultze a15e8f7c72 typo again 2012-01-26 12:48:56 +01:00
Tobias Schultze 2561aa212e typo 2012-01-26 12:48:04 +01:00
Tobias Schultze faa90c9268 updated doc for random function 2012-01-26 12:45:18 +01:00
Tobias Schultze fe663585b7 added tests for random function 2012-01-26 12:19:51 +01:00
Tobias Schultze 6f5ceeec10 Made the random function more versatile 2012-01-26 02:32:02 +01:00
Fabien Potencier f792b55141 merged branch Tobion/patch-3 (PR #613)
Commits
-------

e81a9e2 Improved random function

Discussion
----------

Improved random function

- dealing with empty array (otherwise PHP warning is raised)
- using array_rand() and thus saving the $keys variable

---------------------------------------------------------------------------

by Tobion at 2012-01-25T12:41:32Z

How about allowing `mt_rand ( int $min , int $max )` with optional parameters to be used when the $values ist not an array?
This would solve use case #612
2012-01-25 16:02:48 +01:00
Tobias Schultze e81a9e2e71 Improved random function 2012-01-25 13:34:39 +01:00
Fabien Potencier db9179c77d tweaked previous merge (no need to duplicate visitors, handlers and the expression parser when parsing a template inside another one) 2012-01-24 19:12:39 +01:00
Fabien Potencier f958d91e79 add a unit test for previous merge 2012-01-24 19:09:28 +01:00
Fabien Potencier b45f6b9bfc merged branch Seldaek/inception (PR #610)
Commits
-------

0d656f5 Add comments
0255764 Updated CHANGELOG
b327a48 Protect the Parser against recursive parsing issues

Discussion
----------

Make the parser Inception-Proof

Spent half a day debugging before I realized what happened, but I'll try to keep a long story short:

When the cache is empty, and the first template containing an assetic `{% javascripts %}` or similar tag is parsed, it will build up the assetic "assets" or recipes cache, this in turn will tokenize and parse all your templates to find assetic tags and cache that information.

At this point the parser is parsing something else in the middle of a parse() call, and since there is a single instance in the environment, it means all the instance vars are messed up and contain incorrect references to the latest TokenStream that was parsed by assetic, etc.

This had two effects on my application, both appearing seemingly randomly because it highly depends on the order of things, the state of your cache and probably other factors:

- The first thing that happened is that a template was compiled using the wrong template filename, which means I had a `__TwigTemplate_abcd` in the file named `dcba.php`, and it would never find the right class.
- The second issue (could not reproduce but I assume it was caused by this as well) is that the parse tree is completely broken and you end up with a parse error because it thinks it's at the end when it's not, or similar problem.

The proposed fix basically pushes/pops all the vars into a stack whenever the parser starts/stops, which worked very effectively here and does not introduce much breakage or complexity.

---------------------------------------------------------------------------

by stof at 2012-01-24T17:28:06Z

@Seldaek are you able to create a reproducible testcase for this (which should be failing before this fix) ? It would avoid further regressions

---------------------------------------------------------------------------

by Seldaek at 2012-01-24T17:45:37Z

I'll try to improve on this according to feedback tomorrow. I saw this enough for today :)

---------------------------------------------------------------------------

by fabpot at 2012-01-24T17:45:49Z

I'm writing some unit tests

---------------------------------------------------------------------------

by Seldaek at 2012-01-24T17:47:02Z

Ok then I'll add @dzuelke's comments real quick.
2012-01-24 19:09:17 +01:00
Jordi Boggiano 0d656f53af Add comments 2012-01-24 18:53:53 +01:00
Fabien Potencier a494438a0c merged branch Seldaek/typo (PR #609)
Commits
-------

d8527fe Fix docblock

Discussion
----------

Fix docblock
2012-01-24 17:59:21 +01:00
Jordi Boggiano 0255764455 Updated CHANGELOG 2012-01-24 17:41:37 +01:00
Jordi Boggiano b327a48a29 Protect the Parser against recursive parsing issues 2012-01-24 17:39:13 +01:00
Jordi Boggiano d8527fe6ca Fix docblock 2012-01-24 17:38:16 +01:00
Fabien Potencier d21592b189 removed duplicated tests 2012-01-24 13:11:53 +01:00
Fabien Potencier 0f9d7ffb4c added the possibility to skip some tests depending on the PHP version 2012-01-24 13:03:09 +01:00
Fabien Potencier a57804d204 fixed typo 2012-01-23 10:19:16 +01:00
Fabien Potencier e81c932e77 made a speed optimization to macro calls when imported via the from tag 2012-01-23 09:22:43 +01:00
Fabien Potencier 58f7fa3574 updated CHANGELOG 2012-01-23 08:58:03 +01:00
Fabien Potencier 883a93bb4d fixed the attribute function when passing arguments (closes #608) 2012-01-23 08:51:52 +01:00
Fabien Potencier f2195cfe3f added some unit tests for macros 2012-01-21 21:40:17 +01:00
Fabien Potencier 88389ac503 Revert "made a speed optimization to macro calls when imported via the from tag"
This reverts commit 3b87da344a.
2012-01-21 21:26:04 +01:00
Fabien Potencier 3b87da344a made a speed optimization to macro calls when imported via the from tag 2012-01-21 21:18:48 +01:00
Fabien Potencier f4512da0e7 merged branch Tobion/patch-2 (PR #606)
Commits
-------

83a3073 typo

Discussion
----------

typo
2012-01-21 07:18:00 +01:00
Tobias Schultze 83a30739b4 typo 2012-01-19 11:11:49 +01:00
Fabien Potencier 96596d5c7f fixed typo in doc (closes #604) 2012-01-19 10:31:26 +01:00