MediaWiki master
|
This is the actual workhorse for Session. More...
Public Member Functions | |
__construct (SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger, HookContainer $hookContainer, $lifetime) | |
addData (array $newData) | |
Add data to the session. | |
canSetUser () | |
Indicate whether the session user info can be changed. | |
delaySave () | |
Delay automatic saving while multiple updates are being made. | |
deregisterSession ( $index) | |
Deregister a Session. | |
dirty () | |
Mark data as dirty. | |
getAllowedUserRights () | |
Fetch the rights allowed the user when this session is active. | |
& | getData () |
Fetch the session data array. | |
getId () | |
Returns the session ID. | |
getLoggedOutTimestamp () | |
Fetch the "logged out" timestamp. | |
getProvider () | |
Fetch the SessionProvider for this session. | |
getProviderMetadata () | |
Fetch provider metadata. | |
getRequest ( $index) | |
Returns the request associated with a Session. | |
getRestrictions () | |
Fetch any restrictions imposed on logins or actions when this session is active. | |
getSession (WebRequest $request) | |
Return a new Session for this backend. | |
getSessionId () | |
Fetch the SessionId object. | |
getUser () | |
Returns the authenticated user for this session. | |
isPersistent () | |
Indicate whether this session is persisted across requests. | |
persist () | |
Make this session persisted across requests. | |
renew () | |
Renew the session by resaving everything. | |
resetId () | |
Changes the session ID. | |
save ( $closing=false) | |
Save the session. | |
setForceHTTPS ( $force) | |
Set whether HTTPS should be forced. | |
setLoggedOutTimestamp ( $ts=null) | |
setProviderMetadata ( $metadata) | |
setRememberUser ( $remember) | |
Set whether the user should be remembered independently of the session ID. | |
setUser ( $user) | |
Set a new user for this session. | |
shouldForceHTTPS () | |
Whether HTTPS should be forced. | |
shouldRememberUser () | |
Indicate whether the user should be remembered independently of the session ID. | |
shutdown () | |
Shut down a session. | |
suggestLoginUsername ( $index) | |
Get a suggested username for the login form. | |
unpersist () | |
Make this session not persisted across requests. | |
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 57 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::__construct | ( | SessionId | $id, |
SessionInfo | $info, | ||
CachedBagOStuff | $store, | ||
LoggerInterface | $logger, | ||
HookContainer | $hookContainer, | ||
$lifetime ) |
SessionId | $id | |
SessionInfo | $info | Session info to populate from |
CachedBagOStuff | $store | Backend data store |
LoggerInterface | $logger | |
HookContainer | $hookContainer | |
int | $lifetime | Session data lifetime in seconds |
Definition at line 146 of file SessionBackend.php.
References MediaWiki\Session\SessionInfo\forceHTTPS(), Wikimedia\ObjectCache\CachedBagOStuff\get(), MediaWiki\Session\SessionId\getId(), MediaWiki\Session\SessionInfo\getId(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Session\SessionInfo\getProvider(), MediaWiki\Session\SessionInfo\getProviderMetadata(), MediaWiki\Session\SessionInfo\getUserInfo(), Wikimedia\ObjectCache\BagOStuff\makeKey(), MediaWiki\Session\SessionBackend\persist(), MediaWiki\MainConfigNames\PHPSessionHandling, 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 582 of file SessionBackend.php.
References wfGetAllCallers().
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::canSetUser | ( | ) |
Indicate whether the session user info can be changed.
Definition at line 443 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::delaySave | ( | ) |
Delay automatic saving while multiple updates are being made.
Calls to save() will not be delayed.
Definition at line 648 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::deregisterSession | ( | $index | ) |
Deregister a Session.
int | $index |
Definition at line 231 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\save(), and MediaWiki\Session\SessionBackend\shutdown().
MediaWiki\Session\SessionBackend::dirty | ( | ) |
Mark data as dirty.
Definition at line 602 of file SessionBackend.php.
References wfGetAllCallers().
MediaWiki\Session\SessionBackend::getAllowedUserRights | ( | ) |
Fetch the rights allowed the user when this session is active.
Definition at line 426 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 571 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::getId | ( | ) |
Returns the session ID.
Definition at line 252 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionManager\deregisterSessionBackend(), MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
MediaWiki\Session\SessionBackend::getLoggedOutTimestamp | ( | ) |
Fetch the "logged out" timestamp.
Definition at line 512 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
MediaWiki\Session\SessionBackend::getProvider | ( | ) |
Fetch the SessionProvider for this session.
Definition at line 309 of file SessionBackend.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\getAllowedUserRights(), and MediaWiki\Session\SessionProvider\getAllowedUserRights().
MediaWiki\Session\SessionBackend::getProviderMetadata | ( | ) |
Fetch provider metadata.
Definition at line 538 of file SessionBackend.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\getAllowedUserRights().
MediaWiki\Session\SessionBackend::getRequest | ( | $index | ) |
Returns the request associated with a Session.
int | $index | Session index |
Definition at line 407 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::getRestrictions | ( | ) |
Fetch any restrictions imposed on logins or actions when this session is active.
Definition at line 435 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::getSession | ( | WebRequest | $request | ) |
Return a new Session for this backend.
WebRequest | $request |
Definition at line 219 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::getSessionId | ( | ) |
Fetch the SessionId object.
Definition at line 261 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionManager\changeBackendId(), and MediaWiki\Session\SessionManager\deregisterSessionBackend().
MediaWiki\Session\SessionBackend::getUser | ( | ) |
Returns the authenticated user for this session.
Definition at line 418 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
MediaWiki\Session\SessionBackend::isPersistent | ( | ) |
Indicate whether this session is persisted across requests.
For example, if cookies are set.
Definition at line 320 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::persist | ( | ) |
Make this session persisted across requests.
If the session is already persistent, equivalent to calling $this->renew().
Definition at line 330 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\persist(), and MediaWiki\Session\SessionBackend\renew().
Referenced by MediaWiki\Session\SessionBackend\__construct(), MediaWiki\Session\SessionBackend\persist(), 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 618 of file SessionBackend.php.
References wfGetAllCallers().
Referenced by MediaWiki\Session\SessionBackend\persist().
MediaWiki\Session\SessionBackend::resetId | ( | ) |
Changes the session ID.
Definition at line 269 of file SessionBackend.php.
References MediaWiki\Session\PHPSessionHandler\isEnabled().
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 677 of file SessionBackend.php.
References MediaWiki\User\User\saveSettings().
Referenced by MediaWiki\Session\SessionBackend\deregisterSession(), and MediaWiki\Session\SessionBackend\shutdown().
MediaWiki\Session\SessionBackend::setForceHTTPS | ( | $force | ) |
Set whether HTTPS should be forced.
bool | $force |
Definition at line 495 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::setLoggedOutTimestamp | ( | $ts = null | ) |
int | null | $ts |
Definition at line 519 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::setProviderMetadata | ( | $metadata | ) |
array | null | $metadata |
Definition at line 546 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::setRememberUser | ( | $remember | ) |
Set whether the user should be remembered independently of the session ID.
bool | $remember |
Definition at line 389 of file SessionBackend.php.
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 454 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::shouldForceHTTPS | ( | ) |
Whether HTTPS should be forced.
Definition at line 487 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
MediaWiki\Session\SessionBackend::shouldRememberUser | ( | ) |
Indicate whether the user should be remembered independently of the session ID.
Definition at line 380 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\CookieSessionProvider\setForceHTTPSCookie().
MediaWiki\Session\SessionBackend::shutdown | ( | ) |
Shut down a session.
Definition at line 243 of file SessionBackend.php.
References MediaWiki\Session\SessionBackend\save(), and MediaWiki\Session\SessionBackend\shutdown().
Referenced by MediaWiki\Session\SessionBackend\deregisterSession(), and MediaWiki\Session\SessionBackend\shutdown().
MediaWiki\Session\SessionBackend::suggestLoginUsername | ( | $index | ) |
Get a suggested username for the login form.
int | $index | Session index |
Definition at line 476 of file SessionBackend.php.
MediaWiki\Session\SessionBackend::unpersist | ( | ) |
Make this session not persisted across requests.
Definition at line 349 of file SessionBackend.php.
References MediaWiki\Session\PHPSessionHandler\isEnabled(), and MediaWiki\Session\SessionBackend\persist().