Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1bc6680

Browse files
committed
[HttpFoundation] implement different locking strategies for sessions
1 parent 6f5748e commit 1bc6680

File tree

4 files changed

+263
-118
lines changed

4 files changed

+263
-118
lines changed

UPGRADE-2.6.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Security
105105
HttpFoundation
106106
--------------
107107

108-
* The PdoSessionHandler to store sessions in a database changed significantly.
109-
- It now implements session locking to prevent loss of data by concurrent access to the same session.
108+
* The `PdoSessionHandler` to store sessions in a database changed significantly.
109+
- By default, it now implements session locking to prevent loss of data by concurrent access to the same session.
110110
- It does so using a transaction between opening and closing a session. For this reason, it's not
111111
recommended to use the same database connection that you also use for your application logic.
112112
Otherwise you have to make sure to access your database after the session is closed and committed.
@@ -115,11 +115,16 @@ HttpFoundation
115115
- Since accessing a session now blocks when the same session is still open, it is best practice to
116116
save the session as soon as you don't need to write to it anymore. For example, read-only AJAX
117117
request to a session can save the session immediately after opening it to increase concurrency.
118+
- As alternative to transactional locking you can also use advisory locks which do not require a transaction.
119+
Additionally, you can also revert back to no locking in case you have custom logic to deal with race conditions
120+
like an optimistic concurrency control approach. The locking strategy can be chosen by passing the corresponding
121+
constant as `lock_mode` option, e.g. `new PdoSessionHandler($pdoOrDsn, array('lock_mode' => PdoSessionHandler::LOCK_NONE))`.
122+
For more information please read the class documentation.
118123
- The expected schema of the table changed.
119124
- Session data is binary text that can contain null bytes and thus should also be saved as-is in a
120125
binary column like BLOB. For this reason, the handler does not base64_encode the data anymore.
121126
- A new column to store the lifetime of a session is required. This allows to have different
122127
lifetimes per session configured via session.gc_maxlifetime ini setting.
123128
- You would need to migrate the table manually if you want to keep session information of your users.
124-
- You could use PdoSessionHandler::createTable to initialize a correctly defined table depending on
129+
- You could use `PdoSessionHandler::createTable` to initialize a correctly defined table depending on
125130
the used database vendor.

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ CHANGELOG
55
-----
66

77
* PdoSessionHandler changes
8-
- implemented session locking to prevent loss of data by concurrent access to the same session
9-
- save session data in a binary column without base64_encode
10-
- added lifetime column to the session table which allows to have different lifetimes for each session
8+
- implemented different session locking strategies to prevent loss of data by concurrent access to the same session
9+
- [BC BREAK] save session data in a binary column without base64_encode
10+
- [BC BREAK] added lifetime column to the session table which allows to have different lifetimes for each session
1111
- implemented lazy connections that are only opened when a session is used by either passing a dsn string
1212
explicitly or falling back to session.save_path ini setting
1313
- added a createTable method that initializes a correctly defined table depending on the database vendor

0 commit comments

Comments
 (0)