Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[2.3][HttpFoundation] PDO Session handling enhancements#7634

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@MidnightLightning
Copy link
Contributor

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

PdoSessionHandler class assumes that the PDO object is set to throw exceptions, not errors. I added a line in the constructor to set that attribute, so configuration/query errors are able to be seen and caught a lot easier.

For webhosts that have ini_set restricted (for security purposes), don't just blindly use ini_set if the INI setting is already set to what we need.
The rest of the Handler class assumes that a PDOException gets thrown when there's an issue, but doesn't enforce that requirement. This change explicitly sets that attribute.
Copy link
Member

Choose a reason for hiding this comment

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

please add the curly braces

Copy link
Contributor

Choose a reason for hiding this comment

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

the caller of this code - which created the pdo connection - may not like the fact that pdo will throw exceptions after creating this handler with it..
I think it would be better and less offensive to throw an exception when the ERRMODE is not EXCEPTION - than the user may decide if he likes to switch the ERRMODE (and therfore may change his other code which relies on his pdo connection and this setting) or not.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure thing; that change is added in now!

Don't just change the PDO object attribute without asking; throw an InvalidArgument Exception instead.Check that the ini_set() call succeeded after its called.
Copy link
Contributor

Choose a reason for hiding this comment

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

the message should be more explicit, so a users knows what todo, e.g.

sprintf('"%s" requires PDO connection attribute PDO::ATTR_ERRMODE set to PDO::ERRMODE_EXCEPTION',__CLASS__)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure thing; added in a more descriptive error, with class name, and code fragment to update the PDO error mode. Along the same reasoning, should the error message two lines above be updated to use the class name as well, since "a PdoSessionStorage" doesn't match the class name (PdoSessionHandler)?

Copy link
Contributor

Choose a reason for hiding this comment

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

you should add a unit test proving the exception is thrown as expected when ERRMODE differes from EXCEPTION

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Good point; I added in a few more unit tests for checking that situation, and ensuring a few other runtime errors are indeed getting thrown when they should.

Copy link
Member

Choose a reason for hiding this comment

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

You should use!==

When making a comparison, use the strictest comparison possible, and put the literal comparator first.

Choose a reason for hiding this comment

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

Please revert this to justini_set('session.use_cookies', 1);

@ghost
Copy link

@MidnightLightning - could you please add a CHANGELOG.md entry for this (it's in the HttpfFoundation component root.

@ghost
Copy link

@fabpot - this PR seems ok to merge IMO

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@MidnightLightning@fabpot@staabm@stof@wouterj

[8]ページ先頭

©2009-2025 Movatter.jp