Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpFoundation] Precalculate session expiry timestamp#21857
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
[HttpFoundation] Precalculate session expiry timestamp#21857
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Removed timestamp and lifetime columns in favor of expiry column.Based on the work done insymfony#14625.Fixsymfony#13955.Implemented CR suggestions from nicolas-grekas
de28661 to50e01b1Comparerobfrawley commentedMar 4, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I've added indexes to the new time column for MySQL, SQLite, and PgSQL, but I'm not sure how to do so with the MySQL $sql ="CREATE TABLE$this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY,$this->dataCol BLOB NOT NULL,$this->timeCol INTEGER UNSIGNED NOT NULL, KEY{$this->table}_{$this->timeCol}_idx ($this->timeCol)) COLLATE utf8_bin, ENGINE = InnoDB"; CREATETABLE `sessions` (`sess_id` varbinary(128)NOT NULL,`sess_data` blobNOT NULL,`sess_time`int(10) unsignedNOT NULL,PRIMARY KEY (`sess_id`), KEY`sessions_sess_time_idx` (`sess_time`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin SQLite $sql ="BEGIN; CREATE TABLE$this->table ($this->idCol TEXT NOT NULL PRIMARY KEY,$this->dataCol BLOB NOT NULL,$this->timeCol INTEGER NOT NULL); CREATE INDEX{$this->table}_{$this->timeCol}_idx ON$this->table ($this->timeCol); COMMIT"; BEGIN; CREATE TABLE sessions (sess_idTEXTNOT NULLPRIMARY KEY, sess_data BLOBNOT NULL, sess_timeINTEGERNOT NULL); CREATE INDEX sessions_sess_time_idxON sessions (sess_time);COMMIT; PgSQL $sql ="BEGIN; CREATE TABLE$this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY,$this->dataCol BYTEA NOT NULL,$this->timeCol INTEGER NOT NULL); CREATE INDEX{$this->table}_{$this->timeCol}_idx ON$this->table ($this->timeCol); COMMIT" BEGIN; CREATE TABLE sessions (sess_idVARCHAR(128)NOT NULLPRIMARY KEY, sess_dataBYTEANOT NULL, sess_timeINTEGERNOT NULL); CREATE INDEX sessions_sess_time_idxON sessions (sess_time);COMMIT Anyone have any insight into the proper syntax for the |
…indexes/revert removed code
50e01b1 to0fa0c5aComparesrc/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
UPGRADE-3.3.md Outdated
| HttpFoundation | ||
| -------------- | ||
| * The`PdoSessionHandler` option`db_lifetime_col` has been deprecated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You should add an entry to theUPGRADE-4.0.md file talking about the removal of the column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Added.
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…_col to db_time_col
| }else { | ||
| $mergeStmt->bindParam(':id',$sessionId, \PDO::PARAM_STR); | ||
| $mergeStmt->bindParam(':data',$data, \PDO::PARAM_LOB); | ||
| $mergeStmt->bindParam(':lifetime',$maxlifetime, \PDO::PARAM_INT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this removal looks wrong to me. You need to handle the legacy way too
robfrawleyMar 30, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@stof The legacy tests pass as-is. Should it still be added back with the same assignment as before (the current Unix time)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
same than@stof to me also
robfrawley commentedMar 30, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Calling out again to see if anyone has knowledge of and/or access to an Oracle ( |
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| if ($sessionRows) { | ||
| if ($sessionRows[0][1] +$sessionRows[0][2] <time()) { | ||
| if ($sessionRows[0][1]<time() || (isset($sessionRows[0][2]) &&$sessionRows[0][1]+$sessionRows[0][2] <time())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would base this check on a ternary check forfalse === $this->lifetimeCol, so that it's clearer and easier to spot that this needs to be changed in 4.0
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| $insertStmt->bindParam(':id',$sessionId, \PDO::PARAM_STR); | ||
| $insertStmt->bindValue(':data','', \PDO::PARAM_LOB); | ||
| $insertStmt->bindValue(':lifetime',0, \PDO::PARAM_INT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should be conditional
| case'oci': | ||
| case'pgsql': | ||
| return"SELECT$this->dataCol,$this->lifetimeCol,$this->timeCol FROM$this->table WHERE$this->idCol = :id FOR UPDATE"; | ||
| return"SELECT$this->dataCol,$this->timeCol FROM$this->table WHERE$this->idCol = :id FOR UPDATE"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
conditional also (we should fetch the column whenfalse !== $this->lifetimeCol (same below)
nicolas-grekas commentedAug 7, 2017
ping@robfrawley |
robfrawley commentedAug 10, 2017
Otherwise, I need to amend a few things per some comments/reviews, but the above is a blocker for me ATM, as I have no experience using the |
nicolas-grekas commentedSep 26, 2017
@robfrawley is this really a blocker? I mean: if we are index-less in this iteration, it's fine to me, the code would still be better than today for many ppl, and not worse for oci/sqlsrv, isn't it? WOuld you have time to rebase/finish by the end of the week? |
robfrawley commentedSep 26, 2017
@nicolas-grekas If you don't consider it a blocker to only support indexes on select drivers, I'm happy to rebase and address any remaining comments. Doing so by the end of the week shouldn't be an issue, either. |
nicolas-grekas commentedSep 28, 2017
@robfrawley looking forward to it thanks :) |
nicolas-grekas commentedOct 8, 2017
ping@robfrawley, this might be moved to 4.1 very soon :) |
nicolas-grekas commentedOct 12, 2017
I'm moving this PR to 4.1, we're already late in feat freeze. |
fabpot commentedMar 31, 2018
@robfrawley Still interested in finishing this one? For the record, I agree with@nicolas-grekas about support for OCI and mssql. |
robfrawley commentedApr 4, 2018
@nicolas-grekas@fabpot Fair enough. I can definitely finish this up without index support for oci/sqlsrv. I'll take a look at the end of next week. Likely won't get to it sooner. |
fabpot commentedOct 10, 2018
Anyone willing to take over this one? It's almost finished AFAICR. /cc @symfony/deciders |
fabpot commentedMar 24, 2019
If nobody is willing to take over this one, I'm going to close it. Might be something we can work on in the upcoming Hackaton. |
vargedo commentedJul 22, 2019
+1 this would be great to be merged, we have some issues with this as well. |
azjezz commentedAug 14, 2019
i will take over this one, thanks for your work@robfrawley |
nicolas-grekas commentedAug 15, 2019 • edited by chalasr
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by chalasr
Uh oh!
There was an error while loading.Please reload this page.
Continued in#33169 |
… (azjezz)This PR was merged into the 4.4 branch.Discussion----------[HttpFoundation] Precalculate session expiry timestamp| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets |#13955,#21423,#14625| License | MITContinued work from the original PR#21423 /#21857Commits-------066000a [HttpFoundation] Precalculate session expiry timestamp
Uh oh!
There was an error while loading.Please reload this page.
Continued work from the original PR#21423.
Todo: