[HttpFoundation] Add tests and some CS/docblocks.
[FrameworkBundle] Make use of session API.
[HttpFoundation] Refactor away options property.

It does not make sense to try and store session ini directives since they can be changes outside
of the class as they are part of the global state.

Coding stan
[DoctrineBridge][HttpFoundation] Refactored tests.
[HttpKernel] Mock must invoke constructor.
[HttpFoundation][FrameworkBundle] Separate out mock session storage and stop polluting global namespace.

This makes mock sessions truly mock and not to interfere with global namespace.
Add getters and setters for session name and ID.
Refactor SessionStorage to NativeSessionStorage.

Native here refers to the fact the session storage interacts with real PHP sessions.
Changelog and upgrading changes.
[HttpFoundation] Add more tests.
Fixed an "Array to string conversion" warning when using PHP 5.4. Also affects Symfony2 master.
[FrameworkBundle + WebProfilerBundle] Optimized images and icons with PunnyPNG
[HttpFoundation] Remove hard coded assumptions and replace with API calls.
merged branch stloyd/optimal-images (PR #3573)

Commits
-------

6ad201f [FrameworkBundle + WebProfilerBundle] Optimized images and icons with PunnyPNG

Discussion
----------

[FrameworkBundle + WebProfilerBundle] Optimized images and icons with PunnyPNG

It's addition to #3571, in this one I optimized also some gifs, and replaced some of gifs with png, i.e. `spinner.gif` is almost 1kb smaller.

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

by vicb at 2012-03-12T10:27:59Z

-1 for .gif -> .png (the original images might be used by some 3rd party bundles)

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

by stloyd at 2012-03-12T10:36:51Z

@vicb Do you know any ? Because I'm not =)

Mainly because of change you mentioned this PR is on `master`, so if @fabpot would like it, I can also add note to `UPGRADE-2.1` (`CHANGELOG-2.1` ?) file about this change.

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

by stof at 2012-03-12T11:49:03Z

@stloyd you should update the toolbar templates which contain the base64 encoded version of the icons too so that they use the same version

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

by Tobion at 2012-03-12T12:09:29Z

+1 for png

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

by stloyd at 2012-03-12T12:13:18Z

@stof Added. Thanks for reminding =)

If this PR will be merged, I will send PRs into related bundles (Doctrine, Monolog, SwitfMailer).

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

by fabpot at 2012-03-13T11:04:42Z

I agree with @vicb. No need to convert gifs to pngs; the benefits are not worth the change.

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

by Tobion at 2012-03-13T11:35:56Z

I disagree strongly. A sophisticated framework such as symfony should promote web best practices. PNGs are simply better for icons and image compression is an important topic because of web traffic consumption. Google does not research in JPG replacement (webp) for no reason.

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

by fabpot at 2012-03-14T11:51:31Z

It's not about promoting best practices and I agree that using png would have been better. The point is to not break BC when it is not strictly needed.

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

by Tobion at 2012-03-14T12:14:33Z

How about not replacing gif but instead putting png next to them and using png by default for profiler etc.
So anybody who used these gif images (still don't know who that should be outside the framework, and these are not part of the API) could still use them.

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

by fabpot at 2012-03-14T13:48:44Z

looks like a good compromise to me.

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

by flyboarder at 2012-03-14T16:07:58Z

+1 for side-by-side , gif's can always be removed later.

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

by stloyd at 2012-03-14T22:32:50Z

@fabpot Rebased and restored `.gif` files.
merged branch drak/sessionhandler (PR #3493)

Commits
-------

eb9bf05 [HttpFoundation] Remove hard coded assumptions and replace with API calls.
9a5fc65 [HttpFoundation] Add more tests.
68074a2 Changelog and upgrading changes.
7f33b33 Refactor SessionStorage to NativeSessionStorage.
b12ece0 [HttpFoundation][FrameworkBundle] Separate out mock session storage and stop polluting global namespace.
d687801 [HttpKernel] Mock must invoke constructor.
7b36d0c [DoctrineBridge][HttpFoundation] Refactored tests.
39526df [HttpFoundation] Refactor away options property.
21221f7 [FrameworkBundle] Make use of session API.
cb873b2 [HttpFoundation] Add tests and some CS/docblocks.
a6a9280 [DoctrineBridge] Refactor session storage to handler.
a1c678e [FrameworkBundle] Add session.handler service and handler_id configuration property.
1308312 [HttpFoundation] Add and relocate tests.
88b1170 [HttpFoundation] Refactor tests.
2257a3d [HttpFoundation] Move session handler classes.
0a064d8 [HttpFoundation] Refactor session handlers.
2326707 [HttpFoundation] Split session handler callbacks to separate object.
bb30a44 [HttpFoundation] Prepare to split out session handler callback from session storage.

Discussion
----------

[2.1] Support PHP 5.4 \SessionHandler

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

This patch allows us to add services, like an encryption layer into any session handler without having to alter or inherit any code across any session handler, internal or custom.

The `\SessionHandler` class exposes internal PHP's native internal session save handlers like files, memcache, and sqlite by wrapping the internal callbacks through the class giving user-space the chance to intercept, override and filter them by inheriting from `\SessionHandler`.  I've written a pretty nice use-case at http://docs.php.net/sessionhandler which really shows the power of it. I never considered how to make proper use of the `\SessionHandler` in Symfony2 until I wrote the code example you see in that documentation and also because of the `AbstractSessionStorage` base class got in the way.

It's really trivial to enable support for this in Symfony2 but requires to separate out the actual handlers because inheritance is not suitable.

Obviously, the feature will only work with internal PHP-extension provided handlers under PHP 5.4 and will already work in PHP 5.3 with any custom handler (since they all implement `\SessionHandlerInterface`). Symfony2 will also be the first framework to support these amazing features :-D

The necessary changes are really small but beautiful:

The basic idea is this: https://github.com/drak/symfony/commit/1d55d1ff148125762641a337acde7163d7936e90  removed inheritance and separates out the actual session handler callbacks - the part PHP processes internally.

This is supported by an internal proxy mechanism: https://github.com/drak/symfony/commit/10a36c901e9ee77255954539b2dc3e8920189002

In terms of BC, not much changes net from 2.0:

  - We can restore the deprecated service ID: `session.storage.native`
  - We add a new service ID `session.handler` (and configuration alias `handler_id`) for the actual session handlers.  This defaults to the renamed `session.handler.native_file` session handler (same behaviour just new name and as it's a default there is no BC break).

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

by fabpot at 2012-03-03T12:15:10Z

Looks good to me. Can you update the CHANGELOG and UPGRADE file accordingly and start to update the documentation at symfony/symfony-docs? Thanks for your work, the session handling in Symfony2 is starting to become amazing!

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

by drak at 2012-03-04T11:09:31Z

@fabpot I will start working on documentation this week and get the CHANGELOG/UPGRADING committed shortly.  I'll ping when done.

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

by drak at 2012-03-14T16:48:37Z

@fabpot - This PR is ready now.
[HttpFoundation] Allow flash messages to have multiple messages per type.
[HttpFoundation] Refactored BC Session class methods.

If code has not be refactored for the new API's then
you would still be using the API with one message per $name.
[HttpFoudation] CS, more tests and some optimization.
[HttpFoundation] Update documentation.
[SecurityBundle] Allow switching to the user that is already impersonated (fix #2554)

Disabled exception when switching to the user that is already impersonated, exception is now only thrown when trying to switch to a new user.

Added an Excption exception when switching fails because target user does not exist.

Added funtional tests for switching users.
fixed typos in composer file