rfc:session-read_only-lazy_write
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:session-read_only-lazy_write [2014/03/26 14:41] – Add a discussion link narf | rfc:session-read_only-lazy_write [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Sessions: Improve original RFC about read_only, | + | ====== PHP RFC: Sessions: Improve original RFC about lazy_write ====== |
- | * Version: | + | * Version: |
* Date: 2014-03-14 | * Date: 2014-03-14 | ||
* Author: Andrey Andreev, narf@devilix.net | * Author: Andrey Andreev, narf@devilix.net | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
- | This is a proposal to make an update, or override | + | This is a proposal to make an update, or override |
The [[rfc: | The [[rfc: | ||
Line 16: | Line 16: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | The problems, or missing information on the already accepted solutions are the following: | + | //Note: Previously, here was a description of the issues related |
- | + | ||
- | **read_only** | + | |
- | + | ||
- | 1. The name itself is highly misleading, especially for the context in which it is used. | + | |
- | + | ||
- | What this option does is to cause '' | + | |
- | + | ||
- | session_start([' | + | |
- | + | ||
- | What any programmer would //assume// from the above code with no prior knowledge about it, is the already popular meaning of the term [[http:// | + | |
- | + | ||
- | This could and //will// lead to a lot of confusion, which in turn will result in a lot of malfunctioning userland code. Assume concurrency with the same session ID in the following example: | + | |
- | + | ||
- | // $_SESSION[' | + | |
- | + | ||
- | /* Request 1: */ | + | |
- | session_start([' | + | |
- | + | ||
- | /* Request 2: */ | + | |
- | session_start(); | + | |
- | unset($_SESSION[' | + | |
- | session_write_close(); | + | |
- | // Delete temporary DB rows, i.e. cart contents | + | |
- | + | ||
- | /* Request 1 */ | + | |
- | if ($_SESSION[' | + | |
- | { | + | |
- | // Do something with cart contents, assuming that they exist | + | |
- | } | + | |
- | + | ||
- | This is downright dangerous and ext/ | + | |
- | + | ||
- | Furthermore, | + | |
- | Refer to the [[rfc: | + | |
- | + | ||
- | 2. It is implemented as an option and not a stand-alone function. | + | |
- | + | ||
- | This is somewhat the same issue as described above, but a different API design | + | |
- | + | ||
- | In general, when an option/parameter/argument/ | + | |
- | As it is currently, passing ' | + | |
- | + | ||
- | session_start(); | + | |
- | session_commit(); | + | |
- | + | ||
- | //Maybe//, if session_start() didn't accept //mode// parameters, that would' | + | |
**lazy_write** | **lazy_write** | ||
- | The issues with this option are non-obvious, | + | The issues with this option are non-obvious, |
Below is the description of how it works, that was missing from the original RFC, and is only evident by the patch and the author' | Below is the description of how it works, that was missing from the original RFC, and is only evident by the patch and the author' | ||
Line 108: | Line 62: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | |||
- | ==== On ' | ||
- | |||
- | Unofficially, | ||
- | |||
- | To solve the current problem however, one of the following should be done: | ||
- | |||
- | === Make it a standalone function === | ||
- | |||
- | The feature (start, read and close session) should be available through a stand-alone function, named appropriately to describe what it does. | ||
- | In order to be consistent with the new ability for '' | ||
- | |||
- | bool function session_start_close(array $options = NULL) | ||
- | |||
- | //Note: Feedback on a name better than session_start_close() is welcome.// | ||
- | |||
- | === Rename the option === | ||
- | |||
- | Some people might prefer keeping it as an option instead of a standalone function. If this turns out to be a more popular approach, then the option should be renamed from ' | ||
- | |||
- | ==== On ' | ||
A combination of multiple (but not all) of the following: | A combination of multiple (but not all) of the following: | ||
- | === Merge updateTimestamp() into write() === | + | ==== Merge updateTimestamp() into write() |
SessionHandler:: | SessionHandler:: | ||
Line 143: | Line 76: | ||
* No API changes, at all. | * No API changes, at all. | ||
- | === Add SessionHandler:: | + | Another argument in favor of this solution is that currently, this is the only design allowing userland implementations of ' |
+ | |||
+ | ==== Add SessionHandler:: | ||
updateTimestamp() can be added to SessionHandler at instantiation time, depending on whether the current session.save_handler supports it. This is of course an alternative to moving its logic to write(). | updateTimestamp() can be added to SessionHandler at instantiation time, depending on whether the current session.save_handler supports it. This is of course an alternative to moving its logic to write(). | ||
Line 152: | Line 87: | ||
And this wouldn' | And this wouldn' | ||
- | === Add API exposing $_SESSION changes status === | + | ==== Add API exposing $_SESSION changes status |
This is what was originally asked for via feature request [[https:// | This is what was originally asked for via feature request [[https:// | ||
Line 162: | Line 97: | ||
Either of the above would be sufficient, it doesn' | Either of the above would be sufficient, it doesn' | ||
- | === Always do "lazy writes" | + | ==== Always do "lazy writes" |
There' | There' | ||
Line 174: | Line 109: | ||
PHP 5.6 | PHP 5.6 | ||
- | |||
- | However, due to Beta 1 approaching, | ||
===== Impact to Existing Extensions ===== | ===== Impact to Existing Extensions ===== | ||
Line 185: | Line 118: | ||
None. | None. | ||
- | ===== Open Issues | + | ===== Proposed Voting Choices |
- | TBD: Make sure there are no open issues when the vote starts! | + | * Change API |
+ | * Merge updateTimestamp() into write() | ||
+ | * Declare SessionHandler:: | ||
+ | * Keep original implementation | ||
+ | * Always to lazy writes | ||
+ | * Yes | ||
+ | * No | ||
+ | * Add API to detect $_SESSION changes | ||
+ | * Yes | ||
+ | * No | ||
- | ===== Future Scope ===== | + | Refer to the [[rfc: |
- | Implement the ' | + | Should require 50% + 1 votes. |
- | This would include the following characteristics (only when in read-only mode): | + | ===== Vote ===== |
- | * Use shared(reader) instead of exclusive(writer) locks. | + | Voting period |
- | * Writing | + | |
- | * API to detect the mode in userland code. | + | |
- | ===== Proposed Voting Choices ===== | + | <doodle title=" |
+ | * Merge updateTimestamp() into write() | ||
+ | * Declare SessionHandler:: | ||
+ | * Keep original implementation | ||
+ | </ | ||
- | Still in dicussion, but will most likely match the sections of [[rfc: | ||
- | Should require 50% + 1 votes. | + | |
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | Thank you for voting! | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 226: | Line 182: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | TBD: Keep this updated with features | + | * Making ' |
+ | |||
+ | Almost nobody recognized |
rfc/session-read_only-lazy_write.1395844908.txt.gz · Last modified: 2017/09/22 13:28 (external edit)