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 expiry timestamp#21423
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
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.
nicolas-grekas commentedJan 29, 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.
But what about:
In 4.0, we could then just drop the |
4833d08 to5342d67Compare| $mergeStmt->bindParam(1,$sessionId, \PDO::PARAM_STR); | ||
| $mergeStmt->bindParam(2,$sessionId, \PDO::PARAM_STR); | ||
| $mergeStmt->bindParam(3,$data, \PDO::PARAM_LOB); | ||
| $mergeStmt->bindParam(4,$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.
Setting thelifetimeCol to0 was inlined so we don't need different bind params here.
| * @var string Column for lifetime | ||
| * @deprecated since version 3.3, to be removed in 4.0 | ||
| */ | ||
| private$lifetimeCol ='sess_lifetime'; |
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 this be changed tofalse? Right now the new behavior it opt-in.
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.
it must be opt-in, to keep BC by default
5342d67 tocc4e4a5Comparebcremer commentedFeb 9, 2017
@nicolas-grekas Anything still todo for me here to get this merged? |
nicolas-grekas commentedFeb 9, 2017
LGTM.@Tobion WDYT here? |
| * added the`Cookie::fromString()` method that allows to create a cookie from a | ||
| raw header string | ||
| * PdoSessionHandler: Deprecated the the`lifetime` 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.
Extra "the".
| $this->connectionOptions =isset($options['db_connection_options']) ?$options['db_connection_options'] :$this->connectionOptions; | ||
| $this->lockMode =isset($options['lock_mode']) ?$options['lock_mode'] :$this->lockMode; | ||
| if ($this->lifetimeCol !==false) { |
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.
yoda style (false !== ...) same below
| $this->lockMode =isset($options['lock_mode']) ?$options['lock_mode'] :$this->lockMode; | ||
| if ($this->lifetimeCol !==false) { | ||
| @trigger_error('Using the "db_lifetime_col" option is deprecated since version 3.3 as it will be removed in 4.0.',E_USER_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.
Should give more insights I think, egsprintf('The "%s" column is deprecated since version 3.3 and won't be used anymore in 4.0. Migrate your session database then set the "db_lifetime_col" option to false to opt-in for the new behavior.', $this->lifetimeCol);
I think this deserves an entry in the UPGRADE-3.3+4.0 files, with extended migration info/SQL.
| break; | ||
| default: | ||
| thrownew \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".',$this->driver)); | ||
| if ($this->lifetimeCol ===false) { |
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.
yoda
| }else { | ||
| switch ($this->driver) { | ||
| case'mysql': | ||
| // We use varbinary for the ID column because it prevents unwanted conversions: |
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.
duplicate comment can be removed IMHO
| ); | ||
| $updateStmt->bindParam(':id',$sessionId, \PDO::PARAM_STR); | ||
| $updateStmt->bindParam(':data',$data, \PDO::PARAM_LOB); | ||
| $updateStmt->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.
lifetime should be set to zero so that migration is always possible ("time += lifetime")
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.
Can you expand on what you mean here: where should it to 0?
| // delete the session records that have expired | ||
| $sql ="DELETE FROM$this->table WHERE$this->lifetimeCol +$this->timeCol < :time"; | ||
| $sql ="DELETE FROM$this->table WHERE$this->timeCol < :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.
for BC, we should still consider lifetime when the colum is used, isn't it?
| $sessionRows =$selectStmt->fetchAll(\PDO::FETCH_NUM); | ||
| if ($sessionRows) { | ||
| if ($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.
same here, for BC, we should still use any values in lifetime?
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.
true, the logic must be kept for old session data
| "ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol,$this->lifetimeCol,$this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; | ||
| break; | ||
| if ($this->lifetimeCol ===false) { |
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.
yoda
| { | ||
| $storage =newPdoSessionHandler($this->getMemorySqlitePdo()); | ||
| $storage =newPdoSessionHandler($this->getMemorySqlitePdo(),array('db_lifetime_col' =>false)); | ||
| $storage->open('','sid'); |
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 by mistake?
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.
Removed in#21857
Tobion commentedFeb 9, 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.
Approach seems ok but it's not BC yet. |
nicolas-grekas commentedFeb 18, 2017
@bcremer do you need help - or just a bit more time? please advise :) |
bcremer commentedFeb 18, 2017
@nicolas-grekas It's not my top priority right know. If anybody likes to pickup please do :) Will get back onto it otherwise in a few days or so. |
robfrawley commentedFeb 18, 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.
@bcremer I'm happy to help get this finished up; should I clone your branch, make the required changes, and open a new PR,or would you prefer (and do you have the time) to accept pull requests against your branch (this pull request). |
nicolas-grekas commentedMar 1, 2017
@robfrawley please go with a new PR on your own, keeping the first commit from@bcremer, OK? |
robfrawley commentedMar 1, 2017
@nicolas-grekas Sounds good, will take a look and get something together for tomorrow. |
robfrawley commentedMar 3, 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.
@nicolas-grekas Nevermind my original comment; it was my mistake, though there are some BC breaks in this PR. I've already taken care of the style changes (like the yoda-style comments and others) requested. Will be opening up a new PR shortly, but before doing so, I wanted to ask if you guys would like BC unit tests created with the proper /** * @group legacy * @expectedDeprecation The "%s" column is deprecated since version 3.3 and won't be used anymore in 4.0. Migrate your session database then set the "db_lifetime_col" option to false to opt-in for the new behavior. */ |
nicolas-grekas commentedMar 3, 2017
BC is a requirement yes, and legacy and non-legacy tests would be great yes. |
xabbuh commentedMar 4, 2017
closing in favour of#21857 |
… (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
Removed timestamp and lifetime columns in favor of expiry column.
Based on the work done in#14625.
Fix#13955.