MediaWiki  master
SessionBackend.php
Go to the documentation of this file.
1 <?php
24 namespace MediaWiki\Session;
25 
26 use CachedBagOStuff;
29 use Psr\Log\LoggerInterface;
30 use User;
31 use WebRequest;
32 use Wikimedia\AtEase\AtEase;
33 
52 final class SessionBackend {
54  private $id;
55 
57  private $persist = false;
58 
60  private $remember = false;
61 
63  private $forceHTTPS = false;
64 
66  private $data = null;
67 
69  private $forcePersist = false;
70 
72  private $metaDirty = false;
73 
75  private $dataDirty = false;
76 
78  private $dataHash = null;
79 
81  private $store;
82 
84  private $logger;
85 
87  private $hookRunner;
88 
90  private $lifetime;
91 
93  private $user;
94 
96  private $curIndex = 0;
97 
99  private $requests = [];
100 
102  private $provider;
103 
105  private $providerMetadata = null;
106 
108  private $expires = 0;
109 
111  private $loggedOut = 0;
112 
114  private $delaySave = 0;
115 
117  private $usePhpSessionHandling = true;
120 
122  private $shutdown = false;
123 
132  public function __construct(
133  SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger,
134  HookContainer $hookContainer, $lifetime
135  ) {
136  $phpSessionHandling = \RequestContext::getMain()->getConfig()->get( 'PHPSessionHandling' );
137  $this->usePhpSessionHandling = $phpSessionHandling !== 'disable';
138 
139  if ( $info->getUserInfo() && !$info->getUserInfo()->isVerified() ) {
140  throw new \InvalidArgumentException(
141  "Refusing to create session for unverified user {$info->getUserInfo()}"
142  );
143  }
144  if ( $info->getProvider() === null ) {
145  throw new \InvalidArgumentException( 'Cannot create session without a provider' );
146  }
147  if ( $info->getId() !== $id->getId() ) {
148  throw new \InvalidArgumentException( 'SessionId and SessionInfo don\'t match' );
149  }
150 
151  $this->id = $id;
152  $this->user = $info->getUserInfo() ? $info->getUserInfo()->getUser() : new User;
153  $this->store = $store;
154  $this->logger = $logger;
155  $this->hookRunner = new HookRunner( $hookContainer );
156  $this->lifetime = $lifetime;
157  $this->provider = $info->getProvider();
158  $this->persist = $info->wasPersisted();
159  $this->remember = $info->wasRemembered();
160  $this->forceHTTPS = $info->forceHTTPS();
161  $this->providerMetadata = $info->getProviderMetadata();
162 
163  $blob = $store->get( $store->makeKey( 'MWSession', (string)$this->id ) );
164  if ( !is_array( $blob ) ||
165  !isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) ||
166  !isset( $blob['data'] ) || !is_array( $blob['data'] )
167  ) {
168  $this->data = [];
169  $this->dataDirty = true;
170  $this->metaDirty = true;
171  $this->logger->debug(
172  'SessionBackend "{session}" is unsaved, marking dirty in constructor',
173  [
174  'session' => $this->id,
175  ] );
176  } else {
177  $this->data = $blob['data'];
178  if ( isset( $blob['metadata']['loggedOut'] ) ) {
179  $this->loggedOut = (int)$blob['metadata']['loggedOut'];
180  }
181  if ( isset( $blob['metadata']['expires'] ) ) {
182  $this->expires = (int)$blob['metadata']['expires'];
183  } else {
184  $this->metaDirty = true;
185  $this->logger->debug(
186  'SessionBackend "{session}" metadata dirty due to missing expiration timestamp',
187  [
188  'session' => $this->id,
189  ] );
190  }
191  }
192  $this->dataHash = md5( serialize( $this->data ) );
193  }
194 
200  public function getSession( WebRequest $request ) {
201  $index = ++$this->curIndex;
202  $this->requests[$index] = $request;
203  $session = new Session( $this, $index, $this->logger );
204  return $session;
205  }
206 
212  public function deregisterSession( $index ) {
213  unset( $this->requests[$index] );
214  if ( !$this->shutdown && !count( $this->requests ) ) {
215  $this->save( true );
216  $this->provider->getManager()->deregisterSessionBackend( $this );
217  }
218  }
219 
224  public function shutdown() {
225  $this->save( true );
226  $this->shutdown = true;
227  }
228 
233  public function getId() {
234  return (string)$this->id;
235  }
236 
242  public function getSessionId() {
243  return $this->id;
244  }
245 
250  public function resetId() {
251  if ( $this->provider->persistsSessionId() ) {
252  $oldId = (string)$this->id;
253  $restart = $this->usePhpSessionHandling && $oldId === session_id() &&
255 
256  if ( $restart ) {
257  // If this session is the one behind PHP's $_SESSION, we need
258  // to close then reopen it.
259  session_write_close();
260  }
261 
262  $this->provider->getManager()->changeBackendId( $this );
263  $this->provider->sessionIdWasReset( $this, $oldId );
264  $this->metaDirty = true;
265  $this->logger->debug(
266  'SessionBackend "{session}" metadata dirty due to ID reset (formerly "{oldId}")',
267  [
268  'session' => $this->id,
269  'oldId' => $oldId,
270  ] );
271 
272  if ( $restart ) {
273  session_id( (string)$this->id );
274  AtEase::quietCall( 'session_start' );
275  }
276 
277  $this->autosave();
278 
279  // Delete the data for the old session ID now
280  $this->store->delete( $this->store->makeKey( 'MWSession', $oldId ) );
281  }
282 
283  return $this->id;
284  }
285 
290  public function getProvider() {
291  return $this->provider;
292  }
293 
301  public function isPersistent() {
302  return $this->persist;
303  }
304 
311  public function persist() {
312  if ( !$this->persist ) {
313  $this->persist = true;
314  $this->forcePersist = true;
315  $this->metaDirty = true;
316  $this->logger->debug(
317  'SessionBackend "{session}" force-persist due to persist()',
318  [
319  'session' => $this->id,
320  ] );
321  $this->autosave();
322  } else {
323  $this->renew();
324  }
325  }
326 
330  public function unpersist() {
331  if ( $this->persist ) {
332  // Close the PHP session, if we're the one that's open
333  if ( $this->usePhpSessionHandling && PHPSessionHandler::isEnabled() &&
334  session_id() === (string)$this->id
335  ) {
336  $this->logger->debug(
337  'SessionBackend "{session}" Closing PHP session for unpersist',
338  [ 'session' => $this->id ]
339  );
340  session_write_close();
341  session_id( '' );
342  }
343 
344  $this->persist = false;
345  $this->forcePersist = true;
346  $this->metaDirty = true;
347 
348  // Delete the session data, so the local cache-only write in
349  // self::save() doesn't get things out of sync with the backend.
350  $this->store->delete( $this->store->makeKey( 'MWSession', (string)$this->id ) );
351 
352  $this->autosave();
353  }
354  }
355 
361  public function shouldRememberUser() {
362  return $this->remember;
363  }
364 
370  public function setRememberUser( $remember ) {
371  if ( $this->remember !== (bool)$remember ) {
372  $this->remember = (bool)$remember;
373  $this->metaDirty = true;
374  $this->logger->debug(
375  'SessionBackend "{session}" metadata dirty due to remember-user change',
376  [
377  'session' => $this->id,
378  ] );
379  $this->autosave();
380  }
381  }
382 
388  public function getRequest( $index ) {
389  if ( !isset( $this->requests[$index] ) ) {
390  throw new \InvalidArgumentException( 'Invalid session index' );
391  }
392  return $this->requests[$index];
393  }
394 
399  public function getUser() {
400  return $this->user;
401  }
402 
407  public function getAllowedUserRights() {
408  return $this->provider->getAllowedUserRights( $this );
409  }
410 
415  public function canSetUser() {
416  return $this->provider->canChangeUser();
417  }
418 
426  public function setUser( $user ) {
427  if ( !$this->canSetUser() ) {
428  throw new \BadMethodCallException(
429  'Cannot set user on this session; check $session->canSetUser() first'
430  );
431  }
432 
433  $this->user = $user;
434  $this->metaDirty = true;
435  $this->logger->debug(
436  'SessionBackend "{session}" metadata dirty due to user change',
437  [
438  'session' => $this->id,
439  ] );
440  $this->autosave();
441  }
442 
448  public function suggestLoginUsername( $index ) {
449  if ( !isset( $this->requests[$index] ) ) {
450  throw new \InvalidArgumentException( 'Invalid session index' );
451  }
452  return $this->provider->suggestLoginUsername( $this->requests[$index] );
453  }
454 
459  public function shouldForceHTTPS() {
460  return $this->forceHTTPS;
461  }
462 
467  public function setForceHTTPS( $force ) {
468  if ( $this->forceHTTPS !== (bool)$force ) {
469  $this->forceHTTPS = (bool)$force;
470  $this->metaDirty = true;
471  $this->logger->debug(
472  'SessionBackend "{session}" metadata dirty due to force-HTTPS change',
473  [
474  'session' => $this->id,
475  ] );
476  $this->autosave();
477  }
478  }
479 
484  public function getLoggedOutTimestamp() {
485  return $this->loggedOut;
486  }
487 
492  public function setLoggedOutTimestamp( $ts = null ) {
493  $ts = (int)$ts;
494  if ( $this->loggedOut !== $ts ) {
495  $this->loggedOut = $ts;
496  $this->metaDirty = true;
497  $this->logger->debug(
498  'SessionBackend "{session}" metadata dirty due to logged-out-timestamp change',
499  [
500  'session' => $this->id,
501  ] );
502  $this->autosave();
503  }
504  }
505 
511  public function getProviderMetadata() {
513  }
514 
520  public function setProviderMetadata( $metadata ) {
521  if ( $metadata !== null && !is_array( $metadata ) ) {
522  throw new \InvalidArgumentException( '$metadata must be an array or null' );
523  }
524  if ( $this->providerMetadata !== $metadata ) {
525  $this->providerMetadata = $metadata;
526  $this->metaDirty = true;
527  $this->logger->debug(
528  'SessionBackend "{session}" metadata dirty due to provider metadata change',
529  [
530  'session' => $this->id,
531  ] );
532  $this->autosave();
533  }
534  }
535 
545  public function &getData() {
546  return $this->data;
547  }
548 
556  public function addData( array $newData ) {
557  $data = &$this->getData();
558  foreach ( $newData as $key => $value ) {
559  if ( !array_key_exists( $key, $data ) || $data[$key] !== $value ) {
560  $data[$key] = $value;
561  $this->dataDirty = true;
562  $this->logger->debug(
563  'SessionBackend "{session}" data dirty due to addData(): {callers}',
564  [
565  'session' => $this->id,
566  'callers' => wfGetAllCallers( 5 ),
567  ] );
568  }
569  }
570  }
571 
576  public function dirty() {
577  $this->dataDirty = true;
578  $this->logger->debug(
579  'SessionBackend "{session}" data dirty due to dirty(): {callers}',
580  [
581  'session' => $this->id,
582  'callers' => wfGetAllCallers( 5 ),
583  ] );
584  }
585 
592  public function renew() {
593  if ( time() + $this->lifetime / 2 > $this->expires ) {
594  $this->metaDirty = true;
595  $this->logger->debug(
596  'SessionBackend "{callers}" metadata dirty for renew(): {callers}',
597  [
598  'session' => $this->id,
599  'callers' => wfGetAllCallers( 5 ),
600  ] );
601  if ( $this->persist ) {
602  $this->forcePersist = true;
603  $this->logger->debug(
604  'SessionBackend "{session}" force-persist for renew(): {callers}',
605  [
606  'session' => $this->id,
607  'callers' => wfGetAllCallers( 5 ),
608  ] );
609  }
610  }
611  $this->autosave();
612  }
613 
621  public function delaySave() {
622  $this->delaySave++;
623  return new \Wikimedia\ScopedCallback( function () {
624  if ( --$this->delaySave <= 0 ) {
625  $this->delaySave = 0;
626  $this->save();
627  }
628  } );
629  }
630 
635  private function autosave() {
636  if ( $this->delaySave <= 0 ) {
637  $this->save();
638  }
639  }
640 
650  public function save( $closing = false ) {
651  $anon = $this->user->isAnon();
652 
653  if ( !$anon && $this->provider->getManager()->isUserSessionPrevented( $this->user->getName() ) ) {
654  $this->logger->debug(
655  'SessionBackend "{session}" not saving, user {user} was ' .
656  'passed to SessionManager::preventSessionsForUser',
657  [
658  'session' => $this->id,
659  'user' => $this->user,
660  ] );
661  return;
662  }
663 
664  // Ensure the user has a token
665  // @codeCoverageIgnoreStart
666  if ( !$anon && !$this->user->getToken( false ) ) {
667  $this->logger->debug(
668  'SessionBackend "{session}" creating token for user {user} on save',
669  [
670  'session' => $this->id,
671  'user' => $this->user,
672  ] );
673  $this->user->setToken();
674  if ( !wfReadOnly() ) {
675  // Promise that the token set here will be valid; save it at end of request
676  $user = $this->user;
677  \DeferredUpdates::addCallableUpdate( function () use ( $user ) {
678  $user->saveSettings();
679  } );
680  }
681  $this->metaDirty = true;
682  }
683  // @codeCoverageIgnoreEnd
684 
685  if ( !$this->metaDirty && !$this->dataDirty &&
686  $this->dataHash !== md5( serialize( $this->data ) )
687  ) {
688  $this->logger->debug(
689  'SessionBackend "{session}" data dirty due to hash mismatch, {expected} !== {got}',
690  [
691  'session' => $this->id,
692  'expected' => $this->dataHash,
693  'got' => md5( serialize( $this->data ) ),
694  ] );
695  $this->dataDirty = true;
696  }
697 
698  if ( !$this->metaDirty && !$this->dataDirty && !$this->forcePersist ) {
699  return;
700  }
701 
702  $this->logger->debug(
703  'SessionBackend "{session}" save: dataDirty={dataDirty} ' .
704  'metaDirty={metaDirty} forcePersist={forcePersist}',
705  [
706  'session' => $this->id,
707  'dataDirty' => (int)$this->dataDirty,
708  'metaDirty' => (int)$this->metaDirty,
709  'forcePersist' => (int)$this->forcePersist,
710  ] );
711 
712  // Persist or unpersist to the provider, if necessary
713  if ( $this->metaDirty || $this->forcePersist ) {
714  if ( $this->persist ) {
715  foreach ( $this->requests as $request ) {
716  $request->setSessionId( $this->getSessionId() );
717  $this->provider->persistSession( $this, $request );
718  }
719  if ( !$closing ) {
720  $this->checkPHPSession();
721  }
722  } else {
723  foreach ( $this->requests as $request ) {
724  if ( $request->getSessionId() === $this->id ) {
725  $this->provider->unpersistSession( $request );
726  }
727  }
728  }
729  }
730 
731  $this->forcePersist = false;
732 
733  if ( !$this->metaDirty && !$this->dataDirty ) {
734  return;
735  }
736 
737  // Save session data to store, if necessary
738  $metadata = $origMetadata = [
739  'provider' => (string)$this->provider,
740  'providerMetadata' => $this->providerMetadata,
741  'userId' => $anon ? 0 : $this->user->getId(),
742  'userName' => User::isValidUserName( $this->user->getName() ) ? $this->user->getName() : null,
743  'userToken' => $anon ? null : $this->user->getToken(),
744  'remember' => !$anon && $this->remember,
745  'forceHTTPS' => $this->forceHTTPS,
746  'expires' => time() + $this->lifetime,
747  'loggedOut' => $this->loggedOut,
748  'persisted' => $this->persist,
749  ];
750 
751  $this->hookRunner->onSessionMetadata( $this, $metadata, $this->requests );
752 
753  foreach ( $origMetadata as $k => $v ) {
754  if ( $metadata[$k] !== $v ) {
755  throw new \UnexpectedValueException( "SessionMetadata hook changed metadata key \"$k\"" );
756  }
757  }
758 
759  $flags = $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY;
760  $flags |= CachedBagOStuff::WRITE_SYNC; // write to all datacenters
761  $this->store->set(
762  $this->store->makeKey( 'MWSession', (string)$this->id ),
763  [
764  'data' => $this->data,
765  'metadata' => $metadata,
766  ],
767  $metadata['expires'],
768  $flags
769  );
770 
771  $this->metaDirty = false;
772  $this->dataDirty = false;
773  $this->dataHash = md5( serialize( $this->data ) );
774  $this->expires = $metadata['expires'];
775  }
776 
781  private function checkPHPSession() {
782  if ( !$this->checkPHPSessionRecursionGuard ) {
783  $this->checkPHPSessionRecursionGuard = true;
784  $reset = new \Wikimedia\ScopedCallback( function () {
785  $this->checkPHPSessionRecursionGuard = false;
786  } );
787 
788  if ( $this->usePhpSessionHandling && session_id() === '' && PHPSessionHandler::isEnabled() &&
789  SessionManager::getGlobalSession()->getId() === (string)$this->id
790  ) {
791  $this->logger->debug(
792  'SessionBackend "{session}" Taking over PHP session',
793  [
794  'session' => $this->id,
795  ] );
796  session_id( (string)$this->id );
797  AtEase::quietCall( 'session_start' );
798  }
799  }
800  }
801 
802 }
MediaWiki\Session\SessionInfo\forceHTTPS
forceHTTPS()
Whether this session should only be used over HTTPS.
Definition: SessionInfo.php:277
MediaWiki\Session\SessionId\getId
getId()
Get the ID.
Definition: SessionId.php:53
MediaWiki\Session\SessionBackend\shouldRememberUser
shouldRememberUser()
Indicate whether the user should be remembered independently of the session ID.
Definition: SessionBackend.php:361
MediaWiki\Session\SessionBackend\getUser
getUser()
Returns the authenticated user for this session.
Definition: SessionBackend.php:399
MediaWiki\Session\SessionBackend\getRequest
getRequest( $index)
Returns the request associated with a Session.
Definition: SessionBackend.php:388
MediaWiki\Session\SessionBackend\getProviderMetadata
getProviderMetadata()
Fetch provider metadata.
Definition: SessionBackend.php:511
MediaWiki\Session\SessionBackend\$logger
LoggerInterface $logger
Definition: SessionBackend.php:84
MediaWiki\Session\SessionBackend\$curIndex
int $curIndex
Definition: SessionBackend.php:96
BagOStuff\WRITE_SYNC
const WRITE_SYNC
Bitfield constants for set()/merge(); these are only advisory.
Definition: BagOStuff.php:89
MediaWiki\Session\SessionBackend\getId
getId()
Returns the session ID.
Definition: SessionBackend.php:233
MediaWiki\Session\SessionBackend\$shutdown
bool $shutdown
Definition: SessionBackend.php:122
MediaWiki\Session\SessionBackend\$expires
int $expires
Definition: SessionBackend.php:108
MediaWiki\Session\SessionBackend\$id
SessionId $id
Definition: SessionBackend.php:54
MediaWiki\Session\SessionBackend\persist
persist()
Make this session persisted across requests.
Definition: SessionBackend.php:311
MediaWiki\Session\SessionBackend\setUser
setUser( $user)
Set a new user for this session.
Definition: SessionBackend.php:426
MediaWiki\Session\SessionBackend\getProvider
getProvider()
Fetch the SessionProvider for this session.
Definition: SessionBackend.php:290
MediaWiki\Session\PHPSessionHandler\isEnabled
static isEnabled()
Test whether the handler is installed and enabled.
Definition: PHPSessionHandler.php:103
MediaWiki\Session\SessionBackend\setLoggedOutTimestamp
setLoggedOutTimestamp( $ts=null)
Set the "logged out" timestamp.
Definition: SessionBackend.php:492
MediaWiki\Session\SessionInfo\getId
getId()
Return the session ID.
Definition: SessionInfo.php:187
MediaWiki\Session\SessionBackend\getData
& getData()
Fetch the session data array.
Definition: SessionBackend.php:545
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1104
MediaWiki\Session\SessionBackend\__construct
__construct(SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger, HookContainer $hookContainer, $lifetime)
Definition: SessionBackend.php:132
User\isValidUserName
static isValidUserName( $name)
Is the input a valid username?
Definition: User.php:976
MediaWiki\Session\SessionBackend\resetId
resetId()
Changes the session ID.
Definition: SessionBackend.php:250
serialize
serialize()
Definition: ApiMessageTrait.php:138
MediaWiki\Session\SessionBackend\getSession
getSession(WebRequest $request)
Return a new Session for this backend.
Definition: SessionBackend.php:200
MediaWiki\Session\SessionBackend\deregisterSession
deregisterSession( $index)
Deregister a Session.
Definition: SessionBackend.php:212
CachedBagOStuff\get
get( $key, $flags=0)
Get an item with the given key.
Definition: CachedBagOStuff.php:59
MediaWiki\Session\SessionBackend\autosave
autosave()
Save the session, unless delayed.
Definition: SessionBackend.php:635
MediaWiki\Session\SessionBackend\$forceHTTPS
bool $forceHTTPS
Definition: SessionBackend.php:63
MediaWiki\Session\SessionBackend\shutdown
shutdown()
Shut down a session.
Definition: SessionBackend.php:224
MediaWiki\Session\SessionBackend\$dataHash
string $dataHash
Used to detect subarray modifications.
Definition: SessionBackend.php:78
MediaWiki\Session\SessionBackend\$user
User $user
Definition: SessionBackend.php:93
MediaWiki\Session\Session
Manages data for an an authenticated session.
Definition: Session.php:48
MediaWiki\Session\SessionProvider
A SessionProvider provides SessionInfo and support for Session.
Definition: SessionProvider.php:80
MediaWiki\Session\SessionInfo\getProvider
getProvider()
Return the provider.
Definition: SessionInfo.php:179
$blob
$blob
Definition: testCompression.php:70
MediaWiki\Session\SessionBackend\$metaDirty
bool $metaDirty
Definition: SessionBackend.php:72
MediaWiki\Session\SessionBackend\$store
CachedBagOStuff $store
Definition: SessionBackend.php:81
MediaWiki\Session\SessionBackend\$forcePersist
bool $forcePersist
Definition: SessionBackend.php:69
MediaWiki\Session\SessionBackend\addData
addData(array $newData)
Add data to the session.
Definition: SessionBackend.php:556
MediaWiki\Session\SessionBackend\$loggedOut
int $loggedOut
Definition: SessionBackend.php:111
MediaWiki\Session\SessionBackend\dirty
dirty()
Mark data as dirty.
Definition: SessionBackend.php:576
MediaWiki\Session
Definition: BotPasswordSessionProvider.php:24
MediaWiki\Session\SessionInfo\wasPersisted
wasPersisted()
Return whether the session is persisted.
Definition: SessionInfo.php:242
User\saveSettings
saveSettings()
Save this user's settings into the database.
Definition: User.php:3658
MediaWiki\Session\SessionBackend\setForceHTTPS
setForceHTTPS( $force)
Set whether HTTPS should be forced.
Definition: SessionBackend.php:467
MediaWiki\Session\SessionBackend\$persist
bool $persist
Definition: SessionBackend.php:57
MediaWiki\Session\SessionInfo\getProviderMetadata
getProviderMetadata()
Return provider metadata.
Definition: SessionInfo.php:250
MediaWiki\Session\SessionBackend\$checkPHPSessionRecursionGuard
bool $checkPHPSessionRecursionGuard
Definition: SessionBackend.php:119
MediaWiki\Session\SessionManager\getGlobalSession
static getGlobalSession()
Get the "global" session.
Definition: SessionManager.php:114
MediaWiki\Session\SessionBackend\$data
array null $data
Definition: SessionBackend.php:66
MediaWiki\Session\SessionBackend\getSessionId
getSessionId()
Fetch the SessionId object.
Definition: SessionBackend.php:242
CachedBagOStuff
Wrapper around a BagOStuff that caches data in memory.
Definition: CachedBagOStuff.php:36
MediaWiki\Session\SessionBackend\shouldForceHTTPS
shouldForceHTTPS()
Whether HTTPS should be forced.
Definition: SessionBackend.php:459
CachedBagOStuff\makeKey
makeKey( $class,... $components)
Make a cache key, scoped to this instance's keyspace.
Definition: CachedBagOStuff.php:153
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:451
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:43
wfGetAllCallers
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
Definition: GlobalFunctions.php:1404
MediaWiki\Session\SessionBackend\getAllowedUserRights
getAllowedUserRights()
Fetch the rights allowed the user when this session is active.
Definition: SessionBackend.php:407
MediaWiki\Session\SessionInfo
Value object returned by SessionProvider.
Definition: SessionInfo.php:34
MediaWiki\Session\SessionBackend\isPersistent
isPersistent()
Indicate whether this session is persisted across requests.
Definition: SessionBackend.php:301
MediaWiki\Session\SessionBackend\$lifetime
int $lifetime
Definition: SessionBackend.php:90
MediaWiki\Session\SessionBackend\renew
renew()
Renew the session by resaving everything.
Definition: SessionBackend.php:592
MediaWiki\Session\SessionBackend\getLoggedOutTimestamp
getLoggedOutTimestamp()
Fetch the "logged out" timestamp.
Definition: SessionBackend.php:484
MediaWiki\Session\SessionBackend\delaySave
delaySave()
Delay automatic saving while multiple updates are being made.
Definition: SessionBackend.php:621
MediaWiki\Session\SessionId
Value object holding the session ID in a manner that can be globally updated.
Definition: SessionId.php:38
MediaWiki\Session\SessionBackend\$provider
SessionProvider $provider
provider
Definition: SessionBackend.php:102
MediaWiki\Session\SessionBackend\setRememberUser
setRememberUser( $remember)
Set whether the user should be remembered independently of the session ID.
Definition: SessionBackend.php:370
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:44
MediaWiki\Session\SessionBackend\$dataDirty
bool $dataDirty
Definition: SessionBackend.php:75
MediaWiki\Session\SessionBackend\$requests
WebRequest[] $requests
Session requests.
Definition: SessionBackend.php:99
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:23
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:55
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
Definition: DeferredUpdates.php:145
MediaWiki\Session\SessionBackend\save
save( $closing=false)
Save the session.
Definition: SessionBackend.php:650
MediaWiki\Session\SessionBackend\$hookRunner
HookRunner $hookRunner
Definition: SessionBackend.php:87
MediaWiki\Session\SessionBackend\canSetUser
canSetUser()
Indicate whether the session user info can be changed.
Definition: SessionBackend.php:415
MediaWiki\Session\SessionBackend\setProviderMetadata
setProviderMetadata( $metadata)
Set provider metadata.
Definition: SessionBackend.php:520
MediaWiki\Session\SessionBackend\unpersist
unpersist()
Make this session not persisted across requests.
Definition: SessionBackend.php:330
MediaWiki\Session\SessionBackend\suggestLoginUsername
suggestLoginUsername( $index)
Get a suggested username for the login form.
Definition: SessionBackend.php:448
MediaWiki\Session\SessionBackend\$usePhpSessionHandling
bool $usePhpSessionHandling
Definition: SessionBackend.php:117
MediaWiki\Session\SessionBackend\checkPHPSession
checkPHPSession()
For backwards compatibility, open the PHP session when the global session is persisted.
Definition: SessionBackend.php:781
MediaWiki\Session\SessionBackend\$remember
bool $remember
Definition: SessionBackend.php:60
MediaWiki\Session\SessionInfo\getUserInfo
getUserInfo()
Return the user.
Definition: SessionInfo.php:234
MediaWiki\Session\SessionBackend\$providerMetadata
array null $providerMetadata
provider-specified metadata
Definition: SessionBackend.php:105
MediaWiki\Session\SessionInfo\wasRemembered
wasRemembered()
Return whether the user was remembered.
Definition: SessionInfo.php:269
MediaWiki\Session\SessionBackend\$delaySave
int $delaySave
Definition: SessionBackend.php:114
BagOStuff\WRITE_CACHE_ONLY
const WRITE_CACHE_ONLY
Definition: BagOStuff.php:90
MediaWiki\Session\SessionBackend
This is the actual workhorse for Session.
Definition: SessionBackend.php:52