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

[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

Conversation

@robfrawley
Copy link
Contributor

@robfrawleyrobfrawley commentedMar 3, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets#13955,#21423,#14625
LicenseMIT
Doc PRTBA

Continued work from the original PR#21423.

Todo:

  • Provide legacy tests
  • Fix code style (such as yoda style)
  • Add indexes to time column (only done for MySQL, SQLite, and PgSQL)
  • Re-implement some removed code for BC
  • Add docs to UPGRADE*.md files including SQL for changing to new behavior
  • Add deprecation/removal info to UPGRADE*.md files

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
@robfrawleyrobfrawley changed the title[WIP] Precalculate session expiry timestamp[WIP] [HttpFoundation] Precalculate session expiry timestampMar 3, 2017
@robfrawleyrobfrawleyforce-pushed thefeature-precalculate-session-expiry-timestamp branch fromde28661 to50e01b1CompareMarch 3, 2017 17:28
@nicolas-grekasnicolas-grekas changed the title[WIP] [HttpFoundation] Precalculate session expiry timestamp[HttpFoundation] Precalculate session expiry timestampMar 3, 2017
@nicolas-grekasnicolas-grekas added this to the3.x milestoneMar 4, 2017
@robfrawley
Copy link
ContributorAuthor

robfrawley commentedMar 4, 2017
edited
Loading

I've added indexes to the new time column for MySQL, SQLite, and PgSQL, but I'm not sure how to do so with theoci orsqlsrv drivers. Here are the "create table" statements I have updated so far:

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 theoci andsqlsrv drivers?

@robfrawleyrobfrawleyforce-pushed thefeature-precalculate-session-expiry-timestamp branch from50e01b1 to0fa0c5aCompareMarch 4, 2017 18:48
HttpFoundation
--------------

* The`PdoSessionHandler` option`db_lifetime_col` has been deprecated.
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 add an entry to theUPGRADE-4.0.md file talking about the removal of the column.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Added.

}else {
$mergeStmt->bindParam(':id',$sessionId, \PDO::PARAM_STR);
$mergeStmt->bindParam(':data',$data, \PDO::PARAM_LOB);
$mergeStmt->bindParam(':lifetime',$maxlifetime, \PDO::PARAM_INT);
Copy link
Member

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

Copy link
ContributorAuthor

@robfrawleyrobfrawleyMar 30, 2017
edited
Loading

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)?

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

azjezz reacted with thumbs up emoji
@robfrawley
Copy link
ContributorAuthor

robfrawley commentedMar 30, 2017
edited
Loading

Calling out again to see if anyone has knowledge of and/or access to an Oracle (oci driver) or MSSQL Server (sqlsrv driver); we still need to add indexes to theCREATE TABLE statements for these drivers, as has been done for themysql,sqlite, andpgsql drivers already.


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())) {

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


$insertStmt->bindParam(':id',$sessionId, \PDO::PARAM_STR);
$insertStmt->bindValue(':data','', \PDO::PARAM_LOB);
$insertStmt->bindValue(':lifetime',0, \PDO::PARAM_INT);

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";

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
Copy link
Member

ping@robfrawley

@robfrawley
Copy link
ContributorAuthor

#21857 (comment):

Calling out again to see if anyone has knowledge of and/or access to an Oracle (oci driver) or MSSQL Server (sqlsrv driver); we still need to add indexes to the CREATE TABLE statements for these drivers, as has been done for the mysql, sqlite, and pgsql drivers already.

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 theoci andsqlsrv drivers, and no access to these databases to test, either.

@nicolas-grekas
Copy link
Member

@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
Copy link
ContributorAuthor

@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
Copy link
Member

@robfrawley looking forward to it thanks :)

@nicolas-grekas
Copy link
Member

ping@robfrawley, this might be moved to 4.1 very soon :)

@nicolas-grekasnicolas-grekas modified the milestones:3.4,4.1Oct 12, 2017
@nicolas-grekas
Copy link
Member

I'm moving this PR to 4.1, we're already late in feat freeze.

@fabpot
Copy link
Member

@robfrawley Still interested in finishing this one? For the record, I agree with@nicolas-grekas about support for OCI and mssql.

@robfrawley
Copy link
ContributorAuthor

@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.

@nicolas-grekasnicolas-grekas modified the milestones:4.1,nextApr 20, 2018
@fabpot
Copy link
Member

Anyone willing to take over this one? It's almost finished AFAICR. /cc @symfony/deciders

@fabpot
Copy link
Member

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
Copy link

+1 this would be great to be merged, we have some issues with this as well.

@azjezz
Copy link
Contributor

i will take over this one, thanks for your work@robfrawley

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedAug 15, 2019
edited by chalasr
Loading

Continued in#33169
Thank you@robfrawley!

nicolas-grekas added a commit that referenced this pull requestAug 20, 2019
… (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
@nicolas-grekasnicolas-grekas modified the milestones:next,4.4Oct 27, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhxabbuh left review comments

@stofstofstof requested changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

9 participants

@robfrawley@nicolas-grekas@fabpot@vargedo@azjezz@stof@xabbuh@carsonbot@bcremer

[8]ページ先頭

©2009-2025 Movatter.jp