Skip to content

[DoctrineBridge][DBAL] Add PdoHandler-like $options #20288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

[DoctrineBridge][DBAL] Add PdoHandler-like $options #20288

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 24, 2016

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR symfony/symfony-docs#7132

Small PR to incorporate the options that are available to PdoSessionHandler into the DbalSessionHandler. I do not like being forced to use pre-defined values, especially when they go against the code standards of my current project.

  • Update unit tests
  • Gather feedback for my changes

@ghost ghost changed the title [DoctrineBridge] Add PdoHandler-like $options [WIP][DoctrineBridge] Add PdoHandler-like $options Oct 25, 2016
{
$this->con = $con;
$this->table = $tableName;

$this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about removing the default value of the property and use it here instead, that would be clearer I think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea. I will update the PR with those changes and be sure to include unit tests within that same commit.

@ghost ghost changed the title [WIP][DoctrineBridge] Add PdoHandler-like $options [WIP][DoctrineBridge][DBAL] Add PdoHandler-like $options Nov 10, 2016
@ghost
Copy link
Author

ghost commented Nov 10, 2016

I moved the default values to the constructor for clarity and, added a test.

I've also written documentation for the DbalSessionHandler (see Doc PR) as there was none, at least, none that was specifically about this class (even though one exists for the PdoSessionHandler).

@ghost ghost changed the title [WIP][DoctrineBridge][DBAL] Add PdoHandler-like $options [DoctrineBridge][DBAL] Add PdoHandler-like $options Nov 10, 2016
Hipio and others added 5 commits November 10, 2016 13:06
Small PR to incorporate the options that are available to `PdoSessionHandler` into the `DbalSessionHandler`. I do not like being forced to use pre-defined values, especially when they go against the code standards of my current project.
@fabpot
Copy link
Member

fabpot commented Nov 10, 2016

Honest question: why would someone use DbalSessionHandler vs PdoSessionHandler?

  • This one is slower
  • Everything is abstracted, so this one is not more "convenient"
  • It is more "complex" to configure as you should ensure that it uses a different connection than the one used by the ORM

@ghost
Copy link
Author

ghost commented Nov 10, 2016

That is very good question!

What I know, which isn't a lot, is that this is used purely for the Doctrine ORM. This means that you do not need to mess with the database to add a session table and everything will be handled through Doctrine itself.

It is more "complex" to configure as you should ensure that it uses a different connection than the one used by the ORM

Could you explain this statement? As far as I know I'm using the same connection.

Either way, even if this is worse, the discussion to keep it or not (which is what you seem to be implying) doesn't belong here nor does it affect this PR. Making something more configurable is a good thing, right?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 10, 2016

Of side note: the cache component has a PdoAdapter that looks a lot like the PdoSessionHandler; but it also works with DBAL connections (there is no DbalAdapter). Could have been done here also I guess.

@stof
Copy link
Member

stof commented Nov 10, 2016

@Hipio the first point is a justification for the Schema integration, but this does not justify the handler.

The benefit of the DBAL handler is support for non-PDO drivers of DBAL. But this is the only benefit IMO, and the cache adapter showed that the support could be added in PDOHandler directly (as the DBAL interface matches closely the PDO one)

Could you explain this statement? As far as I know I'm using the same connection.

if you use the same connection, you will face issues, as the session handlers relies on using transactions.
It would be even totally impossible if the DBAL handler was based on the new PDO handler instead of the legacy one.

@ghost
Copy link
Author

ghost commented Nov 11, 2016

All I want to do is pass options to the DbalSessionHandler because I do not want to be use the pre-defined values.

If this PR does not contain the right solution to do this, I would like to know what a better solution would be.

@fabpot
Copy link
Member

fabpot commented Nov 11, 2016

@Hipio This PR does the job :) Sorry for having highjacked your PR with a side discussion that it indeed totally orthogonal to the changes you propose here.

We are in code freeze right now, so this PR will be merged after the release of 3.2.

@xabbuh xabbuh added this to the 3.3 milestone Nov 11, 2016
@Tobion
Copy link
Contributor

Tobion commented Nov 12, 2016

This was already proposed before, see arguments in #13136

@fabpot
Copy link
Member

fabpot commented Nov 12, 2016

The main arguments against this change are there: #14710#issuecomment-104189679

Closing then.

@Potherca
Copy link

@Tobion states:

This was already proposed before, see arguments in #13136

But I'm not entirely sure I understand what is being said in that thread. As @Hipio said:

If this PR does not contain the right solution to do this, I would like to know what a better solution would be.

I would also like to know, if this is not the way to go, what is the way to implement a fix that will be accepted for configuring the DbalSessionHandler?

@stof
Copy link
Member

stof commented Nov 12, 2016

@Potherca we started a discussion about the fact that DbalSessionHandler itself is not the way to go. Switch to the PdoSessionHandler, and you will win the configurability.

@Potherca
Copy link

The application I am working with uses Doctrine for everything, this includes sessions. I looks like switching to the PdoSessionHandler will gain me configurability at the cost of loosing the functionality of having session database handling being done by Doctrine.

Or am I missing something?

@Potherca
Copy link

Also, does my comment belong here or should I move it over to #20501?

@nicolas-grekas nicolas-grekas modified the milestones: 3.x, 3.3 Mar 24, 2017
@nicolas-grekas nicolas-grekas modified the milestones: 3.3, 3.x Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants