Commit Graph

1988 Commits

Author SHA1 Message Date
Fabien Potencier
741859dc47 merged branch canni/user_comparable_interface2 (PR #2927)
Commits
-------

e23d452 Add info about BC Break to CHANGELOG-2.1
d7ffeb5 Add some more tests, and enforce boolean return value of interface implementations.
9d3a49f When method name is `hasUserChanged` the return boolean should be true (to match question semantics) and false when user has not changed, this commits inverts return statements.
c57b528 Add note about `AdvancedUserInterface`.
3682f62 Refactor `isUserChanged` to `hasUserChanged`
56db4a1 Change names to Equatable
680b108 Suggested fixes ;)
9386583 [BC Break][Security] Moved user comparsion logic out of UserInterface As discussed on IRC meetings and in PR #2669 I came up with implementation. This is option2, I think more elegant.

Discussion
----------

[BC Break][Security][Option2] Moved user comparsion logic out of UserInterface

As discussed on IRC meetings and in PR #2669 I came up with implementation.
This is option2, I think more elegant.

BC break: yes
Feature addition: no/feature move
Symfony2 test pass: yes
Symfony2 test written: yes
Todo: decide about naming

[![Build Status](https://secure.travis-ci.org/canni/symfony.png)](http://travis-ci.org/canni/symfony)

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

by schmittjoh at 2011-12-19T19:33:24Z

This looks much better than the previous PR. Thanks!

One thing, we also discussed this on Doctrine, the name "comparable" is used in most programming languages to perform a real compare operation that is ">", "<", or "=". In this case though, we are specifically interested in equality of two objects (we cannot establish a natural order between these objects). Java has no such interface as all objects naturally have an equals() method, .NET uses "Equatable" which looks a bit odd. Not sure if there are better names.

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

by canni at 2011-12-19T19:34:52Z

I think this is best of "both worlds" we have nice full-featured implementation suitable for most, and if someone needs advanced compare logic just implements interface. @stof @schmittjoh, what do you think?

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

by stof at 2011-12-19T19:36:55Z

@canni I already commented on the code, and I agree with @schmittjoh that the naming can be confusing

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

by jmikola at 2011-12-20T17:33:22Z

I don't mean to bikeshed, but I strongly agree with @schmittjoh about implications of "compare". I'm not concerned with the interface name so much as I am with `compareUser()`. Given that this method returns a boolean, I think it's best to prefix it with `is` (e.g. `isSameUser`, `isUserEqualTo`) or `equals` (e.g. `equalsUser`).

In this PR, the Token class is implementing the interface, so I think having "User" in the method name is a good idea. Naturally, if the interface was intended for User classes, we could do without it.

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

by canni at 2011-12-20T19:00:00Z

@jmikola in this PR Token class does not implement any additional interface, and `compareUser` is `private` and used internally. I don't stand still after this names, I'll update PR as soon as some decision about naming will be done.

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

by jmikola at 2011-12-21T02:29:59Z

@canni: My mistake, I got confused between the Token method and interface method, which you've since renamed in canni/symfony@fcfcd1087b.

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

by mvrhov at 2011-12-21T06:09:45Z

hm. Now I'm going to bike shed. Wouldn't the proper function name be hasUserChanged?

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

by stof at 2011-12-21T10:58:38Z

it would probably be bettter. The meaning of ``true`` and ``false`` would then be the opposite of the current ones but this is not an issue IMO as it is a different method

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

by jstout24 at 2011-12-27T18:08:49Z

@canni nice job

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

by fabpot at 2011-12-30T14:59:11Z

The method `isUserChanged()` must be rename. What about `hasUserChanged()` as @mvrhov suggested or `isUserDifferent()`?

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

by canni at 2012-01-02T11:44:05Z

@fabpot done.

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

by fabpot at 2012-01-02T18:13:40Z

The only missing thing I can think of is adding some unit tests.

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

by canni at 2012-01-10T20:16:25Z

@fabpot is there anything more you think that should done in this PR?

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

by stof at 2012-01-10T20:38:46Z

@canni can you rebase your branch ? it conflicts with the current master according to github

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

by canni at 2012-01-10T20:56:55Z

@stof done.

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

by fabpot at 2012-01-12T18:06:00Z

@canni: Can you just add some information in the CHANGELOG and in the UPGRADE file? That's all I need to merge this PR now. Thanks a lot.

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

by canni at 2012-01-12T18:16:32Z

@fabpot done, and no problem :)
2012-01-12 19:26:40 +01:00
Victor Berchet
c0ad1ac170 [HttpKernel] Minor fixes in the Stopwatch 2012-01-10 22:23:16 +01:00
Dariusz Górecki
d7ffeb5844 Add some more tests, and enforce boolean return value of interface implementations. 2012-01-10 21:55:05 +01:00
Dariusz Górecki
9386583b19 [BC Break][Security] Moved user comparsion logic out of UserInterface
As discussed on IRC meetings and in PR #2669 I came up with implementation.
This is option2, I think more elegant.

BC break: yes
Feature addition: no/feature move
Symfony2 test pass: yes
Symfony2 test written: yes
Todo: feedback needed
2012-01-10 21:54:56 +01:00
Jordi Boggiano
bea7a9c865 [Console] Fix tests on windows 2012-01-09 17:05:16 +01:00
Fabien Potencier
4ad7e0e4dd merged branch Seldaek/console_opts2 (PR #3061)
Commits
-------

c7ab9ba [Console] Allow redefinition of application options descriptions

Discussion
----------

[Console] Allow redefinition of application options descriptions

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes

This allows you to redefine an `InputOption` as long as it keeps the same semantic (same default, same name, same alias, same modes). There are two purposes:

- Modifying the description with a more accurate one
- Making sure the option appears in your commands' help

Concrete example: I often want to provide a verbose version of commands. It's an elegant and very common pattern, but I basically can't document what is going to happen if you do `--verbose` since the base Application already defines `--verbose`. Also the `--verbose` option does not appear when you do `console <command> --help`, which means people probably won't think of using that option.
2012-01-09 12:31:41 +01:00
Fabien Potencier
61975a1b3d [Console] tweaked previous merge 2012-01-09 12:22:03 +01:00
Fabien Potencier
4f8f2d4f47 merged branch Seldaek/console_opts (PR #3060)
Commits
-------

7f7b853 [Console] Format simple arrays nicer

Discussion
----------

[Console] Format simple arrays nicer

Minor cosmetic adjustment for simple (i.e. with sequential numeric keys) arrays
2012-01-09 12:15:01 +01:00
Fabien Potencier
ca8dc87940 merged 2.0 2012-01-09 11:51:30 +01:00
Jordi Boggiano
c9129e51fe Fix Console tests on windows 2012-01-09 10:04:20 +01:00
Tobias Schultze
17284937f6 made the assertions in the RequestTest more explicit and improved PHPDoc 2012-01-09 06:33:53 +01:00
Jordi Boggiano
c7ab9ba7ec [Console] Allow redefinition of application options descriptions 2012-01-09 00:42:35 +01:00
Jordi Boggiano
7f7b853d79 [Console] Format simple arrays nicer 2012-01-09 00:03:43 +01:00
Eric Clemmons
01fcb1bdd7 Updated GetSetMethodNormalizerTest to expect camelCased functions instead of lowercased 2012-01-08 13:55:41 -08:00
Fabien Potencier
561cde7743 merged branch digitalkaoz/bugfix_2730_v4 (PR #3052)
Commits
-------

9441c46 [DependencyInjection] PhpDumper, fixes #2730

Discussion
----------

[DependencyInjection] PhpDumper, fixes #2730

Hey, this PR fixes #2730, if no parameters are set, the constructor wont get passed a ParameterBag

Bug fix: yes (#2730)
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes

3rd and last try ;) this time i think its all fine
2012-01-07 16:41:16 +01:00
Dariusz Górecki
3702541b5a Add tests 2012-01-07 16:30:46 +01:00
Christophe Coevoet
9bc41d00d1 [HttpFoundation] Fixed #3053 2012-01-07 14:27:33 +01:00
digitalkaoz
9441c46bb6 [DependencyInjection] PhpDumper, fixes #2730 2012-01-06 21:20:08 +01:00
Victor Berchet
dcee6fffea [TwigBridge] Improve test coverage 2012-01-06 08:35:36 +01:00
stealth35
f4890c24f9 [Translation] Po/MoFileLoader parse plurization rules 2012-01-03 18:44:44 +01:00
Igor Wiedler
7ae93483f9 [streaming] Document and test that Transfer-Encoding is absent 2012-01-02 20:21:31 +01:00
Igor Wiedler
83c23ca0be [streaming] Do not set a Transfer-Encoding header of chunked
Apache expects the response to already be in chunked format in that case,
which causes it to not deliver the streamed body.

If no Content-Length is set on the response, web servers will automatically
switch to chunked Transfer-Encoding, and handle the chunking for you.

Nginx does not share the issue that apache has, but will add the Content-
Length header too.
2012-01-02 19:50:39 +01:00
Fabien Potencier
ce6399e254 [TwigBridge] added a way to specify a default domain for a Twig template (via the 'trans_default_domain' tag)
Note that the tag only influences the current templates. It has no effect on included files to avoid unwanted side-effects.
2012-01-02 17:48:19 +01:00
Fabien Potencier
6a052fb788 [TwigBridge] removed obsolete file 2012-01-02 17:48:16 +01:00
Fabien Potencier
c73e034229 [TwigBridge] added missing transchoice filters whe extracting translations from templates 2012-01-02 17:08:10 +01:00
Fabien Potencier
cadf3d4243 [HttpKernel] fixed doubled results for the file profiler (closes #2915) 2012-01-02 12:10:17 +01:00
Fabien Potencier
66a18f3239 [BrowserKit] first attempt at fixing CookieJar (closes #2209) 2011-12-31 16:32:51 +01:00
Fabien Potencier
716d002ef5 merged branch jmikola/MongoDbProfilerStorageTest (PR #3008)
Commits
-------

3ef0594 [HttpKernel] Fix missing $method argument in MongoDbProfilerStorageTest

Discussion
----------

[HttpKernel] Fix missing $method argument in MongoDbProfilerStorageTest

```
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
```

This test case fixes failures related to a signature change for ProfilerStorageInterface::find(). See: 1aef4e806b and 5f2226807c.

This was easily missed as the test case is skipped unless a MongoDB server is running.
2011-12-31 10:23:48 +01:00
Jeremy Mikola
3ef0594e74 [HttpKernel] Fix missing $method argument in MongoDbProfilerStorageTest
This test case fixes failures related to a signature change for ProfilerStorageInterface::find(). See: 1aef4e806b and 5f2226807c.
2011-12-31 03:10:55 -05:00
Fabien Potencier
899e252032 merged branch symfony/streaming (PR #2935)
Commits
-------

887c0e9 moved EngineInterface::stream() to a new StreamingEngineInterface to keep BC with 2.0
473741b added the possibility to change a StreamedResponse callback after its creation
8717d44 moved a test in the constructor
e44b8ba made some cosmetic changes
0038d1b [HttpFoundation] added support for streamed responses

Discussion
----------

[HttpFoundation] added support for streamed responses

To stream a Response, use the StreamedResponse class instead of the
standard Response class:

    $response = new StreamedResponse(function () {
        echo 'FOO';
    });

    $response = new StreamedResponse(function () {
        echo 'FOO';
    }, 200, array('Content-Type' => 'text/plain'));

As you can see, a StreamedResponse instance takes a PHP callback instead of
a string for the Response content. It's up to the developer to stream the
response content from the callback with standard PHP functions like echo.
You can also use flush() if needed.

From a controller, do something like this:

    $twig = $this->get('templating');

    return new StreamedResponse(function () use ($templating) {
        $templating->stream('BlogBundle:Annot:streamed.html.twig');
    }, 200, array('Content-Type' => 'text/html'));

If you are using the base controller, you can use the stream() method instead:

    return $this->stream('BlogBundle:Annot:streamed.html.twig');

You can stream an existing file by using the PHP built-in readfile() function:

    new StreamedResponse(function () use ($file) {
        readfile($file);
    }, 200, array('Content-Type' => 'image/png');

Read http://php.net/flush for more information about output buffering in PHP.

Note that you should do your best to move all expensive operations to
be "activated/evaluated/called" during template evaluation.

Templates
---------

If you are using Twig as a template engine, everything should work as
usual, even if are using template inheritance!

However, note that streaming is not supported for PHP templates. Support
is impossible by design (as the layout is rendered after the main content).

Exceptions
----------

Exceptions thrown during rendering will be rendered as usual except that
some content might have been rendered already.

Limitations
-----------

As the getContent() method always returns false for streamed Responses, some
event listeners won't work at all:

* Web debug toolbar is not available for such Responses (but the profiler works fine);
* ESI is not supported.

Also note that streamed responses cannot benefit from HTTP caching for obvious
reasons.

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

by Seldaek at 2011/12/21 06:34:13 -0800

Just an idea: what about exposing flush() to twig? Possibly in a way that it will not call it if the template is not streaming. That way you could always add a flush() after your </head> tag to make sure that goes out as fast as possible, but it wouldn't mess with non-streamed responses. Although it appears flush() doesn't affect output buffers, so I guess it doesn't need anything special.

When you say "ESI is not supported.", that means only the AppCache right? I don't see why this would affect Varnish, but then again as far as I know Varnish will buffer if ESI is used so the benefit of streaming there is non-existent.

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

by cordoval at 2011/12/21 08:04:21 -0800

wonder what the use case is for streaming a response, very interesting.

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

by johnkary at 2011/12/21 08:19:48 -0800

@cordoval Common use cases are present fairly well by this RailsCast video: http://railscasts.com/episodes/266-http-streaming

Essentially it allows faster fetching of web assets (JS, CSS, etc) located in the &lt;head>&lt;/head>, allowing those assets to be fetched as soon as possible before the remainder of the content body is computed and sent to the browser. The end goal is to improve page load speed.

There are other uses cases too like making large body content available quickly to the service consuming it. Think if you were monitoring a live feed of JSON data of newest Twitter comments.

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

by lsmith77 at 2011/12/21 08:54:35 -0800

How does this relate the limitations mentioned in:
http://yehudakatz.com/2010/09/07/automatic-flushing-the-rails-3-1-plan/

Am I right to understand that due to how twig works we are not really streaming the content pieces when we call render(), but instead the entire template with its layout is rendered and only then will we flush? or does it mean that the render call will work its way to the top level layout template and form then on it can send the content until it hits another block, which it then first renders before it continues to send the data?

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

by stof at 2011/12/21 09:02:53 -0800

@lsmith77 this is why the ``stream`` method calls ``display`` in Twig instead of ``render``. ``display`` uses echo to print the output of the template line by line (and blocks are simply method calls in the middle). Look at your compiled templates to see it (the ``doDisplay`` method)
Rendering a template with Twig simply use an output buffer around the rendering.

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

by fabpot at 2011/12/21 09:24:33 -0800

@lsmith77: We don't have the Rails problem thanks to Twig as the order of execution is the right one by default (the layout is executed first); it means that we can have the flush feature without any change to how the core works. As @stof mentioned, we are using `display`, not `render`, so we are streaming your templates for byte one.

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

by fabpot at 2011/12/21 09:36:41 -0800

@Seldaek: yes, I meant ESI with the PHP reverse proxy.

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

by fabpot at 2011/12/21 09:37:34 -0800

@Seldaek: I have `flush()` support for Twig on my todo-list. As you mentioned, It should be trivial to implement.

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

by fzaninotto at 2011/12/21 09:48:18 -0800

How do streaming responses deal with assets that must be called in the head, but are declared in the body?

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

by fabpot at 2011/12/21 09:52:12 -0800

@fzaninotto: What do you mean?

With Twig, your layout is defined with blocks ("holes"). These blocks are overridden by child templates, but evaluated as they are encountered in the layout. So, everything works as expected.

As noted in the commit message, this does not work with PHP templates for the problems mentioned in the Rails post (as the order of execution is not the right one -- the child template is first evaluated and then the layout).

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

by fzaninotto at 2011/12/21 10:07:35 -0800

I was referring to using Assetic. Not sure if this compiles to Twig the same way as javascript and stylesheet blocks placed in the head - and therefore executed in the right way.

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

by fabpot at 2011/12/21 10:34:59 -0800

@Seldaek: I've just added a `flush` tag in Twig 1.5: 1d6dfad4f5

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

by catchamonkey at 2011/12/21 13:29:22 -0800

I'm really happy you've got this into the core, it's a great feature to have! Good work.
2011-12-31 08:12:02 +01:00
Fabien Potencier
d12f5b202c [Routing] removed trailing slash support for routes that are not available for GET/HEAD methods (as the redirection will always occurs with a GET/HEAD request, closes #2626) 2011-12-30 19:30:23 +01:00
Fabien Potencier
7b00662df3 [Routing] fixed wrong namespaces in tests 2011-12-30 19:13:17 +01:00
Fabien Potencier
a78437bba9 Revert "merged branch kriswallsmith/security/demeter-fix (PR #2816)"
This reverts commit 76ba2bc7ac, reversing
changes made to 4730f4303b.
2011-12-30 16:05:26 +01:00
Fabien Potencier
466a8b8f48 Merge branch '2.0'
* 2.0:
  [Tests] Skip segfaulting form test
  Rename test file
  [BrowserKit] added missing @return PHPDoc for the Client::submit() method.
  also test PHP 5.3.2, since this is the official lowest supported PHP version
2011-12-30 15:44:05 +01:00
Joseph Bielawski
4c44023e8b [Tests] Skip segfaulting form test 2011-12-30 15:36:55 +01:00
Olivier Dolbeau
0d3e709e0e Rename test file 2011-12-29 16:30:31 +01:00
Fabien Potencier
23e04e3acb merged 2.0 2011-12-29 09:22:11 +01:00
Bart van den Burg
ced57d8ee5 reverse transform doesn't take a second argument 2011-12-29 09:10:04 +01:00
Fabien Potencier
a01eee8536 merged branch ericclemmons/2884-parameterbag-with-spaces (PR #2976)
Commits
-------

85ca8e3 ParameterBag no longer resolves parameters that have spaces.
99011ca Added tests for ParameterBag parameters with spaces

Discussion
----------

[DependencyInjection] Parameters with spaces are not resolved

Bug fix: yes
Feature addition: no
Backwards compatibility break: no (not likely, according to convention)
Symfony2 tests pass: yes
Fixes the following tickets: #2884

`ParameterBag` currently resolves anything between two `%` signs, which creates issues for any parameters in the DIC that are legitimate text.  This PR enforces the [documented parameter convention](http://symfony.com/doc/2.0/book/service_container.html#service-parameters) so that only `%parameters.with.no_spaces%` are resolved.

I was considering using instead `^%([^\w\._-]+)%$`, but felt that was too constricting & could easily introduce issues with existing applications.
2011-12-28 21:36:04 +01:00
Fabien Potencier
cab70f4083 merged 2.0 2011-12-28 20:44:29 +01:00
Javier Eguíluz
3f2e1b0483 [Console] Updated tests to reflect the change from program to application 2011-12-28 12:44:00 +01:00
Eric Clemmons
99011ca9c9 Added tests for ParameterBag parameters with spaces 2011-12-27 12:48:49 -08:00
Fabien Potencier
f579f72b32 [HttpKernel] added a unit test for previous merge 2011-12-26 22:32:11 +01:00
Drak
79793e442a Coding standards and removing whitespace. 2011-12-24 15:50:47 +05:45
Joseph Bielawski
9daa2a6cc8 [Profiler] Add function to get parent token directly 2011-12-23 09:45:13 +01:00
Fabien Potencier
5b2bc7d7f9 merged 2.0 2011-12-23 08:57:06 +01:00
Christophe Coevoet
373ab4c50f Fixed tests added from 2.0 2011-12-22 17:52:42 +01:00
Christophe Coevoet
24319bb0f4 [DoctrineBridge] Made it possible to change the manager used by the provider 2011-12-22 16:14:12 +01:00
Bart van den Burg
c60f0363de fixed typo 2011-12-22 10:57:47 +01:00
Bart van den Burg
231e79ce0f fixed entity choice list BC break 2011-12-22 10:49:27 +01:00