Skip to content

[HttpFoundation] Fix PdoSessionHandler to work properly with streams #12146

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

Conversation

rybakit
Copy link
Contributor

@rybakit rybakit commented Oct 6, 2014

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

Ref: #10931 (comment)

@@ -498,6 +498,8 @@ private function rollback()
* @param string $sessionId Session ID
*
* @return string The session data
*
* @throws \PDOException
Copy link
Contributor

Choose a reason for hiding this comment

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

every method can throw this. so this is not really helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it because PhpStorm shows a warning otherwise: "PHPDoc comment doesn't contain all necessary @throws tag(s)". Should I remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes because this doesnt only apply to this method.

@Tobion
Copy link
Contributor

Tobion commented Oct 6, 2014

Did you test this class with a real sqlite connection? If so could you please also test the blocking with https://github.com/Tobion/symfony-standard/tree/session-locking-test ?

@rybakit
Copy link
Contributor Author

rybakit commented Oct 6, 2014

I didn't test it with a real sqlite connection as I don't use custom session handlers in my project. I've installed your session-locking-test branch and was able to read and write session data using /write/foo and /read requests. Is it enough or should I do something else to test blocking?

if ($sessionRows) {
return is_resource($sessionRows[0][0])
? stream_get_contents($sessionRows[0][0])
: $sessionRows[0][0];
Copy link
Member

Choose a reason for hiding this comment

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

Can you move everything on one line? Same below, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Tobion
Copy link
Contributor

Tobion commented Oct 6, 2014

Did you update https://github.com/Tobion/symfony-standard/blob/session-locking-test/app/config/config.yml#L46 to use postgres? You can test blocking by loading two pages /write/foo and /read at the same time. Just refresh write and then read. The read page should block until the write finished (which has a delay of 8 sec). Then do the same test with advisory locks by changing https://github.com/Tobion/symfony-standard/blob/session-locking-test/app/config/config.yml#L29 to 1. The behavior should be the same as before.

class MockPdo extends \PDO
{
public $driverName;
public $errorMode;
Copy link
Contributor

Choose a reason for hiding this comment

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

errorMode and driverName can be private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@rybakit
Copy link
Contributor Author

rybakit commented Oct 6, 2014

@Tobion I've tested pgsql driver as you described and it works as expected.

@Tobion
Copy link
Contributor

Tobion commented Oct 6, 2014

Cool thanks. And did pdo_pgsql indeed return a stream for the binary field?

@rybakit
Copy link
Contributor Author

rybakit commented Oct 6, 2014

Yes, and it's mentioned in the manual:

Note:
The bytea fields are returned as streams.

@Tobion
Copy link
Contributor

Tobion commented Oct 6, 2014

👍 Thanks for fixing this and doing functional tests.
In case you also have access to oracle db or mssql, it would be much appreciated to do the same tests for them.

@fabpot
Copy link
Member

fabpot commented Oct 7, 2014

Thank you @rybakit.

@fabpot fabpot closed this in 0476ce8 Oct 7, 2014
@rybakit rybakit deleted the session branch October 7, 2014 18:40
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.

4 participants