MediaWiki
1.33.1
|
This is the actual workhorse for Session. More...
Public Member Functions | |
__construct (SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger, $lifetime) | |
addData (array $newData) | |
Add data to the session. More... | |
canSetUser () | |
Indicate whether the session user info can be changed. More... | |
delaySave () | |
Delay automatic saving while multiple updates are being made. More... | |
deregisterSession ( $index) | |
Deregister a Session. More... | |
dirty () | |
Mark data as dirty. More... | |
getAllowedUserRights () | |
Fetch the rights allowed the user when this session is active. More... | |
& | getData () |
Fetch the session data array. More... | |
getId () | |
Returns the session ID. More... | |
getLoggedOutTimestamp () | |
Fetch the "logged out" timestamp. More... | |
getProvider () | |
Fetch the SessionProvider for this session. More... | |
getProviderMetadata () | |
Fetch provider metadata. More... | |
getRequest ( $index) | |
Returns the request associated with a Session. More... | |
getSession (WebRequest $request) | |
Return a new Session for this backend. More... | |
getSessionId () | |
Fetch the SessionId object. More... | |
getUser () | |
Returns the authenticated user for this session. More... | |
isPersistent () | |
Indicate whether this session is persisted across requests. More... | |
persist () | |
Make this session persisted across requests. More... | |
renew () | |
Renew the session by resaving everything. More... | |
resetId () | |
Changes the session ID. More... | |
save ( $closing=false) | |
Save the session. More... | |
setForceHTTPS ( $force) | |
Set whether HTTPS should be forced. More... | |
setLoggedOutTimestamp ( $ts=null) | |
Set the "logged out" timestamp. More... | |
setProviderMetadata ( $metadata) | |
Set provider metadata. More... | |
setRememberUser ( $remember) | |
Set whether the user should be remembered independently of the session ID. More... | |
setUser ( $user) | |
Set a new user for this session. More... | |
shouldForceHTTPS () | |
Whether HTTPS should be forced. More... | |
shouldRememberUser () | |
Indicate whether the user should be remembered independently of the session ID. More... | |
shutdown () | |
Shut down a session. More... | |
suggestLoginUsername ( $index) | |
Get a suggested username for the login form. More... | |
unpersist () | |
Make this session not persisted across requests. More... | |
Private Member Functions | |
autosave () | |
Save the session, unless delayed. More... | |
checkPHPSession () | |
For backwards compatibility, open the PHP session when the global session is persisted. More... | |
Private Attributes | |
bool | $checkPHPSessionRecursionGuard = false |
int | $curIndex = 0 |
array null | $data = null |
bool | $dataDirty = false |
string | $dataHash = null |
Used to detect subarray modifications. More... | |
int | $delaySave = 0 |
int | $expires = 0 |
bool | $forceHTTPS = false |
bool | $forcePersist = false |
SessionId | $id |
int | $lifetime |
int | $loggedOut = 0 |
LoggerInterface | $logger |
bool | $metaDirty = false |
bool | $persist = false |
SessionProvider | $provider |
provider More... | |
array null | $providerMetadata = null |
provider-specified metadata More... | |
bool | $remember = false |
WebRequest[] | $requests = [] |
Session requests. More... | |
bool | $shutdown = false |
CachedBagOStuff | $store |
bool | $usePhpSessionHandling = true |
User | $user |
This is the actual workhorse for Session.
Most code does not need to use this class, you want \MediaWiki\Session\Session. The exceptions are SessionProviders and SessionMetadata hook functions, which get an instance of this class rather than Session.
The reasons for this split are:
Definition at line 49 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::__construct | ( | SessionId | $id, |
SessionInfo | $info, | ||
CachedBagOStuff | $store, | ||
LoggerInterface | $logger, | ||
$lifetime | |||
) |
SessionId | $id | |
SessionInfo | $info | Session info to populate from |
CachedBagOStuff | $store | Backend data store |
LoggerInterface | $logger | |
int | $lifetime | Session data lifetime in seconds |
Definition at line 125 of file SessionBackend.php.
References $blob, MediaWiki\Session\SessionBackend\$id, MediaWiki\Session\SessionBackend\$lifetime, MediaWiki\Session\SessionBackend\$logger, MediaWiki\Session\SessionBackend\$store, data, MediaWiki\Session\SessionInfo\forceHTTPS(), CachedBagOStuff\get(), MediaWiki\Session\SessionId\getId(), MediaWiki\Session\SessionInfo\getId(), RequestContext\getMain(), MediaWiki\Session\SessionInfo\getProvider(), MediaWiki\Session\SessionInfo\getProviderMetadata(), MediaWiki\Session\SessionInfo\getUserInfo(), CachedBagOStuff\makeKey(), null, MediaWiki\Session\SessionBackend\persist(), serialize(), user, User, MediaWiki\Session\SessionInfo\wasPersisted(), and MediaWiki\Session\SessionInfo\wasRemembered().
MediaWiki\Session\SessionBackend::addData | ( | array | $newData | ) |
Add data to the session.
Overwrites any existing data under the same keys.
array | $newData | Key-value pairs to add to the session |
Definition at line 547 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$data, $value, as, MediaWiki\Session\SessionBackend\getData(), and wfGetAllCallers().
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
|
private |
Save the session, unless delayed.
Definition at line 626 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\delaySave(), and MediaWiki\Session\SessionBackend\save().
Referenced by MediaWiki\Session\SessionBackend\persist(), MediaWiki\Session\SessionBackend\renew(), MediaWiki\Session\SessionBackend\resetId(), MediaWiki\Session\SessionBackend\setForceHTTPS(), MediaWiki\Session\SessionBackend\setLoggedOutTimestamp(), MediaWiki\Session\SessionBackend\setProviderMetadata(), MediaWiki\Session\SessionBackend\setRememberUser(), MediaWiki\Session\SessionBackend\setUser(), and MediaWiki\Session\SessionBackend\unpersist().
MediaWiki\Session\SessionBackend::canSetUser | ( | ) |
Indicate whether the session user info can be changed.
Definition at line 406 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\setUser().
|
private |
For backwards compatibility, open the PHP session when the global session is persisted.
Definition at line 772 of file SessionBackend.php.
References MediaWiki\Session\SessionManager\getGlobalSession(), MediaWiki\Session\SessionBackend\getId(), and MediaWiki\Session\PHPSessionHandler\isEnabled().
Referenced by MediaWiki\Session\SessionBackend\save().
MediaWiki\Session\SessionBackend::delaySave | ( | ) |
Delay automatic saving while multiple updates are being made.
Calls to save() will not be delayed.
Definition at line 612 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\save().
Referenced by MediaWiki\Session\SessionBackend\autosave(), and MediaWiki\Session\SessionManager\getSessionFromInfo().
MediaWiki\Session\SessionBackend::deregisterSession | ( | $index | ) |
Deregister a Session.
int | $index |
Definition at line 203 of file SessionBackend.php.
References captcha-old\count, MediaWiki\Session\SessionBackend\save(), and MediaWiki\Session\SessionBackend\shutdown().
MediaWiki\Session\SessionBackend::dirty | ( | ) |
Mark data as dirty.
Definition at line 567 of file SessionBackend.php.
References wfGetAllCallers().
Referenced by MediaWiki\Session\SessionBackendTest\testSave().
MediaWiki\Session\SessionBackend::getAllowedUserRights | ( | ) |
Fetch the rights allowed the user when this session is active.
Definition at line 398 of file SessionBackend.php.
& MediaWiki\Session\SessionBackend::getData | ( | ) |
Fetch the session data array.
Note the caller is responsible for calling $this->dirty() if anything in the array is changed.
Definition at line 536 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$data.
Referenced by MediaWiki\Session\SessionBackend\addData().
MediaWiki\Session\SessionBackend::getId | ( | ) |
Returns the session ID.
Definition at line 224 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$id.
Referenced by MediaWiki\Session\SessionBackend\checkPHPSession(), MediaWiki\Session\SessionManager\deregisterSessionBackend(), MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession(), and MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::getLoggedOutTimestamp | ( | ) |
Fetch the "logged out" timestamp.
Definition at line 475 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$loggedOut.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::getProvider | ( | ) |
Fetch the SessionProvider for this session.
Definition at line 281 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$provider.
Referenced by MediaWiki\Session\Session\BotPasswordSessionProvider\getAllowedUserRights(), and MediaWiki\Session\SessionProvider\getAllowedUserRights().
MediaWiki\Session\SessionBackend::getProviderMetadata | ( | ) |
Fetch provider metadata.
Definition at line 502 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$providerMetadata.
Referenced by MediaWiki\Session\Session\BotPasswordSessionProvider\getAllowedUserRights().
MediaWiki\Session\SessionBackend::getRequest | ( | $index | ) |
Returns the request associated with a Session.
int | $index | Session index |
Definition at line 379 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::getSession | ( | WebRequest | $request | ) |
Return a new Session for this backend.
WebRequest | $request |
Definition at line 191 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$curIndex, and $request.
MediaWiki\Session\SessionBackend::getSessionId | ( | ) |
Fetch the SessionId object.
Definition at line 233 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$id.
Referenced by MediaWiki\Session\SessionManager\changeBackendId(), MediaWiki\Session\SessionManager\deregisterSessionBackend(), and MediaWiki\Session\SessionBackend\save().
MediaWiki\Session\SessionBackend::getUser | ( | ) |
Returns the authenticated user for this session.
Definition at line 390 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$user.
Referenced by MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession(), and MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::isPersistent | ( | ) |
Indicate whether this session is persisted across requests.
For example, if cookies are set.
Definition at line 292 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$persist.
Referenced by MediaWiki\Session\SessionBackendTest\testSave().
MediaWiki\Session\SessionBackend::persist | ( | ) |
Make this session persisted across requests.
If the session is already persistent, equivalent to calling $this->renew().
Definition at line 302 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\autosave(), and MediaWiki\Session\SessionBackend\renew().
Referenced by MediaWiki\Session\SessionBackend\__construct(), MediaWiki\Session\SessionBackend\renew(), MediaWiki\Session\SessionBackend\save(), and MediaWiki\Session\SessionBackend\unpersist().
MediaWiki\Session\SessionBackend::renew | ( | ) |
Renew the session by resaving everything.
Resets the TTL in the backend store if the session is near expiring, and re-persists the session to any active WebRequests if persistent.
Definition at line 583 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\autosave(), MediaWiki\Session\SessionBackend\persist(), and wfGetAllCallers().
Referenced by MediaWiki\Session\SessionBackend\persist().
MediaWiki\Session\SessionBackend::resetId | ( | ) |
Changes the session ID.
Definition at line 241 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$id, MediaWiki\Session\SessionBackend\autosave(), MediaWiki\Session\PHPSessionHandler\isEnabled(), and string.
MediaWiki\Session\SessionBackend::save | ( | $closing = false | ) |
Save the session.
Update both the backend data and the associated WebRequest(s) to reflect the state of the SessionBackend. This might include persisting or unpersisting the session.
bool | $closing | Whether the session is being closed |
Definition at line 641 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$data, MediaWiki\Session\SessionBackend\$forceHTTPS, MediaWiki\Session\SessionBackend\$id, MediaWiki\Session\SessionBackend\$lifetime, MediaWiki\Session\SessionBackend\$loggedOut, MediaWiki\Session\SessionBackend\$persist, MediaWiki\Session\SessionBackend\$remember, $request, MediaWiki\Session\SessionBackend\$user, DeferredUpdates\addCallableUpdate(), as, MediaWiki\Session\SessionBackend\checkPHPSession(), data, MediaWiki\Session\SessionBackend\getSessionId(), User\isValidUserName(), null, MediaWiki\Session\SessionBackend\persist(), Hooks\run(), User\saveSettings(), serialize(), string, use, user, wfReadOnly(), BagOStuff\WRITE_CACHE_ONLY, and BagOStuff\WRITE_SYNC.
Referenced by MediaWiki\Session\SessionBackend\autosave(), MediaWiki\Session\SessionBackend\delaySave(), MediaWiki\Session\SessionBackend\deregisterSession(), MediaWiki\Session\SessionBackend\shutdown(), and MediaWiki\Session\SessionBackendTest\testSave().
MediaWiki\Session\SessionBackend::setForceHTTPS | ( | $force | ) |
Set whether HTTPS should be forced.
bool | $force |
Definition at line 458 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\autosave().
MediaWiki\Session\SessionBackend::setLoggedOutTimestamp | ( | $ts = null | ) |
Set the "logged out" timestamp.
int | null | $ts |
Definition at line 483 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\autosave().
MediaWiki\Session\SessionBackend::setProviderMetadata | ( | $metadata | ) |
Set provider metadata.
array | null | $metadata |
Definition at line 511 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\autosave().
MediaWiki\Session\SessionBackend::setRememberUser | ( | $remember | ) |
Set whether the user should be remembered independently of the session ID.
bool | $remember |
Definition at line 361 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$remember, and MediaWiki\Session\SessionBackend\autosave().
MediaWiki\Session\SessionBackend::setUser | ( | $user | ) |
Set a new user for this session.
User | $user | User to set on the session. This may become a "UserValue" in the future, or User may be refactored into such. |
Definition at line 417 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$user, MediaWiki\Session\SessionBackend\autosave(), MediaWiki\Session\SessionBackend\canSetUser(), and user.
MediaWiki\Session\SessionBackend::shouldForceHTTPS | ( | ) |
Whether HTTPS should be forced.
Definition at line 450 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$forceHTTPS.
Referenced by MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession(), and MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::shouldRememberUser | ( | ) |
Indicate whether the user should be remembered independently of the session ID.
Definition at line 352 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\$remember.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::shutdown | ( | ) |
Shut down a session.
Definition at line 215 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\save().
Referenced by MediaWiki\Session\SessionBackend\deregisterSession().
MediaWiki\Session\SessionBackend::suggestLoginUsername | ( | $index | ) |
Get a suggested username for the login form.
int | $index | Session index |
Definition at line 439 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::unpersist | ( | ) |
Make this session not persisted across requests.
Definition at line 321 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\autosave(), MediaWiki\Session\PHPSessionHandler\isEnabled(), and MediaWiki\Session\SessionBackend\persist().
|
private |
Definition at line 113 of file SessionBackend.php.
|
private |
Definition at line 90 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\getSession().
Definition at line 63 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\addData(), MediaWiki\Session\SessionBackend\getData(), and MediaWiki\Session\SessionBackend\save().
|
private |
Definition at line 72 of file SessionBackend.php.
Used to detect subarray modifications.
Definition at line 75 of file SessionBackend.php.
|
private |
Definition at line 108 of file SessionBackend.php.
|
private |
Definition at line 102 of file SessionBackend.php.
|
private |
Definition at line 60 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\save(), and MediaWiki\Session\SessionBackend\shouldForceHTTPS().
|
private |
Definition at line 66 of file SessionBackend.php.
|
private |
|
private |
Definition at line 84 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\__construct(), and MediaWiki\Session\SessionBackend\save().
|
private |
Definition at line 105 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\getLoggedOutTimestamp(), and MediaWiki\Session\SessionBackend\save().
|
private |
Definition at line 81 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\__construct().
|
private |
Definition at line 69 of file SessionBackend.php.
|
private |
Definition at line 54 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\isPersistent(), and MediaWiki\Session\SessionBackend\save().
|
private |
provider
Definition at line 96 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\getProvider().
provider-specified metadata
Definition at line 99 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\getProviderMetadata().
|
private |
Definition at line 57 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\save(), MediaWiki\Session\SessionBackend\setRememberUser(), and MediaWiki\Session\SessionBackend\shouldRememberUser().
|
private |
Session requests.
Definition at line 93 of file SessionBackend.php.
|
private |
Definition at line 116 of file SessionBackend.php.
|
private |
Definition at line 78 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\__construct().
|
private |
Definition at line 111 of file SessionBackend.php.
|
private |
Definition at line 87 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\getUser(), MediaWiki\Session\SessionBackend\save(), and MediaWiki\Session\SessionBackend\setUser().