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.
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 <head></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.
* 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
Commits
-------
4c44023 [Tests] Skip segfaulting form test
Discussion
----------
[Tests] Skip segfaulting form test when using PHP <= 5.3.2
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2958http://travis-ci.org/#!/stloyd/symfony/jobs/461563
Commits
-------
dfbed9f also test PHP 5.3.2, since this is the official lowest supported PHP version
Discussion
----------
[WIP] test with PHP 5.3.2 on travis
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: ![Build Status](https://secure.travis-ci.org/lsmith77/symfony.png?branch=travis_test_5_3_2)
Fixes the following tickets: -
---------------------------------------------------------------------------
by lsmith77 at 2011/12/25 16:29:20 -0800
Enable testing against PHP 5.3.2, not sure why its segfaulting PHPUnit. Will check with @loicfrering whats going on there.
---------------------------------------------------------------------------
by lsmith77 at 2011/12/25 17:31:04 -0800
the issue may be inside the ClassLoader .. so we might need to increase the minimal version. but this needs to be confirmed independently.
Commits
-------
0d3e709 Rename test file
Discussion
----------
Just rename MessageCatalogTest in MessageCatalogueTest
This time, in the correct branch...
(see: https://github.com/symfony/symfony/pull/2987)
Commits
-------
7e48f97 Fix speling misteak :)
Discussion
----------
Fix speling misteak :)
Just a little one, but it's in a subtitle.
---------------------------------------------------------------------------
by hhamon at 2011/12/29 08:45:42 -0800
Misteak ? ^^ You misspelled your commit message :)
---------------------------------------------------------------------------
by inanimatt at 2011/12/29 08:48:56 -0800
That was a joke :P
Commits
-------
ced57d8 reverse transform doesn't take a second argument
Discussion
----------
reverse transform doesn't take a second argument
as requested in https://github.com/symfony/symfony/pull/2980
when cherry-picking the earlier commit I found out that some assertSame calls had been changed into assertNull in 2.1, but not in 2.0. This will probably result in some merge problems later. Let me know if and how I should update my commit if this is the case
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.
Commits
-------
41950a6 [WebProfilerBundle] add margin-bottom to caption
Discussion
----------
[WebProfilerBundle] add margin-bottom to caption
---------------------------------------------------------------------------
by fabpot at 2011/12/26 13:15:57 -0800
What does it fix?
---------------------------------------------------------------------------
by havvg at 2011/12/27 02:46:16 -0800
Just a minor design issue with table captions.
Without: http://dl.dropbox.com/u/548684/PR2957/without-margin.png
With: http://dl.dropbox.com/u/548684/PR2957/with-margin.png
I currently hold it in a custom css, but thought it is generic enough to be put into the bundle.
---------------------------------------------------------------------------
by henrikbjorn at 2011/12/27 04:03:53 -0800
@havvg What custom bundle is that ? and what does it show? look interesting
---------------------------------------------------------------------------
by havvg at 2011/12/27 04:40:18 -0800
@henrikbjorn It's a bundle (not published yet, https://github.com/havvg/HavvgCloudcontrolBundle) adding features to fully utilize applications on http://cloudcontrol.com PaaS.
Commits
-------
3f2e1b0 [Console] Updated tests to reflect the change from `program` to `application`
2b64944 [Console][Output] Fixed some minor typos and grammatical errors
96997f1 [Console][Input] Added missing PHPDoc and fixed some minor typos and grammatical errors
855b8af [Console][Helper] Added missing PHPDoc and fixed some minor typos and grammatical errors
3ad02bd [Console][Formatter] Added missing PHPDoc @throws and fixed some minor typos and grammatical errors
33e3f11 [Console] Added a missing PHPDoc and replaced `program` by `application`
Discussion
----------
[Console] Fixed and completed PHPDoc
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
* Fixed minor typos and grammatical errors
* Added missing PHPDoc for some methods
* Added missing @throws
Commits
-------
1bc10e5 Forgotten </trans-unit> tag added
Discussion
----------
Forgotten </trans-unit> tag added
on src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.es.xlf