-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Allow reuse of Session between requests if ID did not change #28433
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
Conversation
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.
Would you mind adding a test case please?
Otherwise, lgtm thanks.
$this->storage->setId($id); | ||
} catch (\Exception $e) { | ||
$exception = $e; | ||
} |
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.
$e = null;
try {
$this->storage->setId($id);
} catch (\Exception $e) {
}
$this->assertNull($e);
same below
@@ -97,6 +97,30 @@ public function testGetId() | |||
$this->assertNotEquals('', $this->storage->getId()); | |||
} | |||
|
|||
public function testSetId() |
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.
testSetIdAfterStart()
?
|
||
$this->assertNull($exception); | ||
|
||
$exception = null; |
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.
no need to reassign
Thank you @tgalopin. |
…f ID did not change (tgalopin) This PR was merged into the 2.8 branch. Discussion ---------- [HttpFoundation] Allow reuse of Session between requests if ID did not change | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13450 | License | MIT | Doc PR | - I stumbled upon the issue from #13450 in a more simple case than what was exposed in the issue. From my understanding, the problem arises when the session is used between an access to the session and a functional test request: because the session was accessed (usually using the container directly), the session has started and the following request fails. This PR checks whether the ID was actually regenerated before throwing (if a setId is called with the same ID, it is the same request context, it shouldn't throw IMO). Not sure I understood everything correctly though, feel free to fix it for me if needed. Commits ------- fd30f4a Allow reuse of Session between requests
I stumbled upon the issue from #13450 in a more simple case than what was exposed in the issue. From my understanding, the problem arises when the session is used between an access to the session and a functional test request: because the session was accessed (usually using the container directly), the session has started and the following request fails.
This PR checks whether the ID was actually regenerated before throwing (if a setId is called with the same ID, it is the same request context, it shouldn't throw IMO).
Not sure I understood everything correctly though, feel free to fix it for me if needed.