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

Use proper error message when session write fails #20807#21421

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
digilist wants to merge2 commits intosymfony:2.8fromdigilist:2.8
Closed

Use proper error message when session write fails #20807#21421

digilist wants to merge2 commits intosymfony:2.8fromdigilist:2.8

Conversation

@digilist
Copy link
Contributor

This improves the error message that is thrown if a session write fails (see#20807)

As there was no way to get the actual handler, I introduced a method on the SessionHandlerProxy. I hope that's okay, otherwise please give me a hint on what to do.

QA
Branch?2.8
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20807
LicenseMIT

/**
* @return \SessionHandlerInterface
*/
publicfunctiongetHandler():\SessionHandlerInterface
Copy link
Member

Choose a reason for hiding this comment

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

The return type is a no-go as Symfony supports PHP 5.x

session_write_close();
try {
session_write_close();
}catch (\ErrorException$e) {
Copy link
Member

Choose a reason for hiding this comment

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

this won't work in prod, as notices and warnings arenot turned into ErrorException exceptions there.

Code must not be written by assuming that the error handler has this behavior

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, currently the session write fails silently in production.

I updated the code to check the last error message and throw a E_USER_WARNING with the corrected message. However, the warning is not logged by default.

Alternatively, we can throw an Excpetion if the write fails, as it is an error anyway. However, it does break BC.

@nicolas-grekas
Copy link
Member

Status: needs work

@nicolas-grekas
Copy link
Member

Instead of relying on some external error handler to trigger the exception, I'd suggest to register a temporary error handler that does the throw.

@digilist
Copy link
ContributorAuthor

That is a good idea! The code is much cleaner now.

$handler =$handler->getHandler();
}

$message =sprintf(
Copy link
Member

Choose a reason for hiding this comment

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

this can be inlined in thetrigger_error() call

@fabpot
Copy link
Member

Thank you@digilist.

@fabpotfabpot closed thisMar 5, 2017
fabpot added a commit that referenced this pull requestMar 5, 2017
… (digilist)This PR was submitted for the 2.8 branch but it was merged into the 3.3-dev branch instead (closes#21421).Discussion----------Use proper error message when session write fails#20807This improves the error message that is thrown if a session write fails (see#20807)As there was no way to get the actual handler, I introduced a method on the SessionHandlerProxy. I hope that's okay, otherwise please give me a hint on what to do.| Q             | A| ------------- | ---| Branch?       | 2.8| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#20807| License       | MITCommits-------c7a44be Use proper error message when session write fails#20807
@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh left review comments

@stofstofstof requested changes

Assignees

No one assigned

Projects

None yet

Milestone

2.8

Development

Successfully merging this pull request may close these issues.

6 participants

@digilist@nicolas-grekas@fabpot@stof@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp