-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Refactor session handling and flash messages #2714
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
Closed
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
a2a8024
[FrameworkBundle] Refactor tests.
f21cfda
[HttpFoundation] Added structured namespacing to session attributes.
d20a1a0
[HttpFoundation] Move flash messages out of Session class and change …
04c5a3a
[HttpFoundation] Introduce a SessionInterface to make session class m…
202bde1
[HttpFoundation] Refactored the FlashBag* changing the way old messag…
6e4ee80
[BC Break][HttpFoundation] Refactored session handling to be true to …
f8ed4d8
[HttpFoundation] Added some new Native*Storage drivers for SQLite and…
e970caa
[HttpFoundation] SessionID is passed by PHP.
5920b69
[HttpFoundation] Add MemcacheSessionStorage driver.
006df6b
[HttpFoundation] Add MemcachedSessionStorage driver.
fe5fb53
[HttpFoundation] Added prefix to storage keys and declared properties.
e415277
[HttpFoundation] Documentation.
c2625c2
[BC Break][FrameworkBundle] Fix unit tests in.
5b15138
[HttpFoundation] Cleaned up constants.
58bc557
[HttpFoundation] remove test, needs to be completely re-written.
fe7bc8d
[HttpFoundation] Refactor test.
13f59b8
[WebProfilerBundle] Removed hack to make flash messages persist for a…
3340eaf
[Security] Refactor session storage driver in test.
e624746
[HttpFoundation] Added NullSessionStorage
402c3bd
[FrameworkBundle] Update session configuration XML.
1083d32
[HttpFoundation] Added native memcached session storage driver.
07dba61
[HttpFoundation] Correct callback names.
37455f3
[HttpFoundation] Remove check for now to allow tests to pass.
51f06a7
[TwigBundle] Refactor test for session management.
efadac3
[HttpFoundation][FrameworkBundle][SecurityBundle] Make parameters con…
af52d9e
Updated changelog and upgrading documentation.
f66987a
[HttpFoundation] FlashBag docblocks and class constants.
d6f779c
[HttpFoundation][FrameworkBundle] FilsyststemSessionStorage drive is …
967eb54
Coding standards, docblocks.
597b400
Typo.
22cd77c
Simplified examples of how to show flash messages.
de9f6df
[HttpFoundation] Add simple flash-message API to SessionInterface.
27383ac
[HttpFoundation] Change attribute namespacing character.
6f3135f
[HttpFoundation] Fix docblock return value.
be6810c
[Bridge/HttpFoundation] Refactored DbalSessionStorage
aee6c8a
[HttpFoundation] Typo fix.
9b0e1df
[HttpFoundation][FrameworkBundle] Moved session attributes to it's ow…
8498d7e
[HttpFoundation][FrameworkBundle] Made configuration of session stora…
3cc1f7e
[HttpFoundation] Allow session.cache_limiter to be forced if really r…
ccb1696
[HttpFoundation] Fix sprintf() calls.
044dca4
Documentation, coding standards and docblocks.
e89a82c
[HttpFoundation][FrameworkBundle][TwigBundle][Bridge/Doctrine] Move b…
eee89d6
[HttpFoundation][FrameworkBundle][SecurityBundle] Introduced mock ses…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,10 @@ | |
namespace Symfony\Bridge\Doctrine\HttpFoundation; | ||
|
||
use Doctrine\DBAL\Platforms\MySqlPlatform; | ||
use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage; | ||
use Symfony\Component\HttpFoundation\AttributeBagInterface; | ||
use Symfony\Component\HttpFoundation\FlashBagInterface; | ||
use Symfony\Component\HttpFoundation\SessionStorage\AbstractSessionStorage; | ||
use Symfony\Component\HttpFoundation\SessionStorage\SessionSaveHandlerInterface; | ||
use Doctrine\DBAL\Driver\Connection; | ||
|
||
/** | ||
|
@@ -12,39 +15,32 @@ | |
* @author Fabien Potencier <[email protected]> | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
class DbalSessionStorage extends NativeSessionStorage | ||
class DbalSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface | ||
{ | ||
/** | ||
* @var Connection | ||
*/ | ||
private $con; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $tableName; | ||
|
||
public function __construct(Connection $con, $tableName = 'sessions', array $options = array()) | ||
/** | ||
* | ||
* @param Connection $con An instance of Connection. | ||
* @param string $tableName Table name. | ||
* @param array $options Session configuration options | ||
* @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) | ||
* @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) | ||
*/ | ||
public function __construct(Connection $con, $tableName = 'sessions', array $options = array(), AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) | ||
{ | ||
parent::__construct($options); | ||
|
||
$this->con = $con; | ||
$this->tableName = $tableName; | ||
} | ||
|
||
/** | ||
* Starts the session. | ||
*/ | ||
public function start() | ||
{ | ||
if (self::$sessionStarted) { | ||
return; | ||
} | ||
|
||
// use this object as the session handler | ||
session_set_save_handler( | ||
array($this, 'sessionOpen'), | ||
array($this, 'sessionClose'), | ||
array($this, 'sessionRead'), | ||
array($this, 'sessionWrite'), | ||
array($this, 'sessionDestroy'), | ||
array($this, 'sessionGC') | ||
); | ||
|
||
parent::start(); | ||
parent::__construct($attributes, $flashes, $options); | ||
} | ||
|
||
/** | ||
|
@@ -102,7 +98,7 @@ public function sessionDestroy($id) | |
* | ||
* @throws \RuntimeException If any old sessions cannot be cleaned | ||
*/ | ||
public function sessionGC($lifetime) | ||
public function sessionGc($lifetime) | ||
{ | ||
try { | ||
$this->con->executeQuery("DELETE FROM {$this->tableName} WHERE sess_time < :time", array( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
typo