This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier b25a8767ad merged branch schmittjoh/dbalSessionStorage (PR #2182)
Commits
-------

3f8e8c9 fixes a session max lifetime handling
3abb7f3 fixed some conflicts with garbage collection
a1888b2 added a dbal session storage

Discussion
----------

Dbal session storage

Adds a session storage based on Doctrine DBAL.

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

by lsmith77 at 2011/09/14 13:39:28 -0700

guess it would be nice to then provide a service inside the DoctrineBundle that reuses a global DoctrineDBAL connection, guess the connection to use would then need to be configured via the doctrine app config.

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

by schmittjoh at 2011/09/14 13:42:34 -0700

I haven't found a sane way to provide automatic configuration that's why I left this to the user to implement. It's also relatively easy:

```yml
services:
    dbal_session_storage:
        class: Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionStorage
        arguments: [@database_connection]

framework:
    session: { storage_id: dbal_session_storage }

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

by stof at 2011/09/14 13:57:48 -0700

@lsmith77 There is an issue about reusing another DBAL connection: if the transaction is aborted by the ORM, the session could be aborted too as you cannot have 2 independent transactions AFAIK

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

by lsmith77 at 2011/09/14 13:59:57 -0700

not sure how this is relevant. i mean why does the transaction need to be left open? just begin, write, commit ..

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

by stof at 2011/09/14 14:02:39 -0700

and what if the transaction of the ORM is still opened (let's say you use SimpleThingsTransactionalBundle) ?

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

by lsmith77 at 2011/09/14 14:06:12 -0700

well thats a bit of an edge case imho. also i wonder if SimpleThingsTransactionalBundle shouldn't make sure that its transaction is closed before the session is written.

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

by schmittjoh at 2011/09/14 14:06:56 -0700

It closes them.

On Wed, Sep 14, 2011 at 11:06 PM, Lukas Kahwe Smith <
reply@reply.github.com>wrote:

> well thats a bit of an edge case imho. also i wonder if
> SimpleThingsTransactionalBundle shouldn't make sure that its transaction is
> closed before the session is written.
>
> --
> Reply to this email directly or view it on GitHub:
> https://github.com/symfony/symfony/pull/2182#issuecomment-2098100
>

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

by stof at 2011/09/14 14:15:02 -0700

@schmittjoh Does it close them **before** writing the session ?

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

by schmittjoh at 2011/09/14 14:44:15 -0700

I think either commit, or rollback is called, but @beberlei can probably answer that better.

Anyway, it is not really related to this PR because it is up to the user which connection is used.

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

by stof at 2011/09/14 14:58:48 -0700

I know that one of them is called. But if they are called after the session is persisted to the DB, a rollback is an issue as it will rollback the session persistence as well.
The PR is indeed fine. What need to be changed is the doc about how to use it, to advocate using a separate connection instead of the default one (which is used in your example)

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

by schmittjoh at 2011/09/15 02:57:34 -0700

There is no doc yet, but lets see what @fabpot thinks of all of this first.

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

by fabpot at 2011/09/15 04:57:57 -0700

Any benefits over using the PDO session storage?

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

by lsmith77 at 2011/09/15 05:00:50 -0700

cleaner code, potentially better support for niche RDBMS, centralized logging and finally afaik DoctrineDBAL has emulation for nested transactions.

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

by schmittjoh at 2011/09/15 05:11:00 -0700

The benefits (for me) are:

- logging queries
- better interoperability with existing build processes (migrations)
- better database interoperability
- re-using existing connection (I don't have the problem that Stof mentioned above)

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

by beberlei at 2011/09/15 06:18:22 -0700

The nested transactions is the problem here as @stof already said. If you reuse the default connection and use nested transactions that fail then this will make your session not save. That is why the docs should recommend you create a second connection for a dbal based session storage, even if it is using the same database. The PDO session storage would be a second connection besides DBAL aswell.

I like the migrations/schema hook though to create the table automatically through schema commands.

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

by fabpot at 2011/09/15 10:45:31 -0700

ok, looks good to me. Can you add some documentation about its usage (like the possible keys for options)? Is it possible to add some tests too?

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

by jdreesen at 2011/09/22 06:34:11 -0700

why did you close this?

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

by schmittjoh at 2011/09/30 06:26:12 -0700

I can't put more time into this PR, however I'm using it for some time already, and there shouldn't be any major issues as it is basically copy/paste from the PDO session.
2011-10-07 14:11:24 +02:00
src/Symfony merged branch schmittjoh/dbalSessionStorage (PR #2182) 2011-10-07 14:11:24 +02:00
tests [Translation] Add failing tests to verify that UTF-8 lang files can't be used with another charset 2011-10-07 11:20:16 +02:00
.gitignore Added vendor directory to .gitignore 2010-06-24 10:44:28 +02:00
autoload.php.dist fixed autoloader when tests are run on a machine without intl installed 2011-07-20 14:27:10 +02:00
CHANGELOG-2.0.md updated CHANGELOG for 2.0.4 2011-10-04 13:46:16 +02:00
CHANGELOG-2.1.md added RouterInterface::getRouteCollection() 2011-09-30 07:48:34 +02:00
check_cs fixed root search path to include only './src' and './tests' 2011-06-08 18:11:05 +02:00
composer.json updated composer.json for 2.1 2011-09-29 17:32:57 +02:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.0.4 2011-10-04 13:46:51 +02:00
LICENSE added the LICENSE file for the YAML component 2011-02-18 11:52:11 +01:00
phpunit.xml.dist [Security] cleaned up opt-in to benchmark test 2011-03-06 20:06:13 +01:00
README.md [README] Adding a small section with information about contributing. 2011-09-23 11:21:11 -05:00
UPDATE.ja.md updated translation of UPDATE file (Japanese RC5 added) 2011-07-30 02:08:25 +09:00
UPDATE.md updated UPDATE file 2011-07-22 17:45:02 +02:00
vendors.php updated vendors for 2.0.4 2011-10-04 13:43:49 +02:00

README

What is Symfony2?

Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Requirements

Symfony2 is only supported on PHP 5.3.2 and up.

Installation

The best way to install Symfony2 is to download the Symfony Standard Edition available at http://symfony.com/download.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony2 can help speed up your development and take the quality of your work to the next level, read the official Symfony2 documentation.

Contributing

Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section.