MediaWiki  1.30.0
MediaWiki\Session\PHPSessionHandler Class Reference

Adapter for PHP's session handling. More...

Inheritance diagram for MediaWiki\Session\PHPSessionHandler:
Collaboration diagram for MediaWiki\Session\PHPSessionHandler:

Public Member Functions

 close ()
 Close the session (handler) More...
 
 destroy ( $id)
 Destroy a session. More...
 
 gc ( $maxlifetime)
 Execute garbage collection. More...
 
 open ( $save_path, $session_name)
 Initialize the session (handler) More...
 
 read ( $id)
 Read session data. More...
 
 setManager (SessionManager $manager, BagOStuff $store, LoggerInterface $logger)
 Set the manager, store, and logger. More...
 
 write ( $id, $dataStr)
 Write session data. More...
 

Static Public Member Functions

static install (SessionManager $manager)
 Install a session handler for the current web request. More...
 
static isEnabled ()
 Test whether the handler is installed and enabled. More...
 
static isInstalled ()
 Test whether the handler is installed. More...
 

Protected Member Functions

 __construct (SessionManager $manager)
 

Static Protected Member Functions

static returnFailure ()
 Workaround for PHP5 bug. More...
 
static returnSuccess ()
 Workaround for PHP5 bug. More...
 

Protected Attributes

bool $enable = false
 Whether PHP session handling is enabled. More...
 
LoggerInterface $logger
 
SessionManager null $manager
 
array $sessionFieldCache = []
 Track original session fields for later modification check. More...
 
BagOStuff null $store
 
 $warn = true
 

Static Protected Attributes

static PHPSessionHandler $instance = null
 

Private Member Functions

 setEnableFlags ( $PHPSessionHandling)
 Set $this->enable and $this->warn. More...
 

Detailed Description

Adapter for PHP's session handling.

Since
1.27

Definition at line 34 of file PHPSessionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ close()

MediaWiki\Session\PHPSessionHandler::close ( )

Close the session (handler)

Access:\n private For internal use only
Returns
bool|int Success (see self::returnSuccess())

Definition at line 214 of file PHPSessionHandler.php.

References MediaWiki\Session\PHPSessionHandler\returnSuccess().

◆ destroy()

MediaWiki\Session\PHPSessionHandler::destroy (   $id)

Destroy a session.

Access:\n private For internal use only
Parameters
string$idSession id
Returns
bool|int Success (see self::returnSuccess())

Definition at line 362 of file PHPSessionHandler.php.

References MediaWiki\Session\PHPSessionHandler\returnSuccess().

◆ gc()

MediaWiki\Session\PHPSessionHandler::gc (   $maxlifetime)

Execute garbage collection.

Access:\n private For internal use only
Parameters
int$maxlifetimeMaximum session life time (ignored)
Returns
bool|int Success (see self::returnSuccess()) See T135576

Definition at line 383 of file PHPSessionHandler.php.

References MediaWiki\Session\PHPSessionHandler\returnSuccess(), and store.

◆ install()

◆ isEnabled()

◆ isInstalled()

◆ open()

MediaWiki\Session\PHPSessionHandler::open (   $save_path,
  $session_name 
)

Initialize the session (handler)

Access:\n private For internal use only
Parameters
string$save_pathPath used to store session files (ignored)
string$session_nameSession name (ignored)
Returns
bool|int Success (see self::returnSuccess())

Definition at line 199 of file PHPSessionHandler.php.

References MediaWiki\Session\PHPSessionHandler\returnSuccess().

◆ read()

MediaWiki\Session\PHPSessionHandler::read (   $id)

Read session data.

Access:\n private For internal use only
Parameters
string$idSession id
Returns
string Session data

Definition at line 228 of file PHPSessionHandler.php.

◆ returnFailure()

static MediaWiki\Session\PHPSessionHandler::returnFailure ( )
staticprotected

Workaround for PHP5 bug.

See also
self::returnSuccess()
Returns
bool|int

Definition at line 188 of file PHPSessionHandler.php.

References false.

Referenced by MediaWiki\Session\PHPSessionHandler\write().

◆ returnSuccess()

static MediaWiki\Session\PHPSessionHandler::returnSuccess ( )
staticprotected

Workaround for PHP5 bug.

PHP5 has a bug in handling boolean return values for SessionHandlerInterface methods, it expects 0 or -1 instead of true or false. See https://wiki.php.net/rfc/session.user.return-value.

PHP7 and HHVM are not affected.

Todo:
When we drop support for Zend PHP 5, this can be removed.
Returns
bool|int

Definition at line 178 of file PHPSessionHandler.php.

References true.

Referenced by MediaWiki\Session\PHPSessionHandler\close(), MediaWiki\Session\PHPSessionHandler\destroy(), MediaWiki\Session\PHPSessionHandler\gc(), MediaWiki\Session\PHPSessionHandler\open(), and MediaWiki\Session\PHPSessionHandler\write().

◆ setEnableFlags()

MediaWiki\Session\PHPSessionHandler::setEnableFlags (   $PHPSessionHandling)
private

Set $this->enable and $this->warn.

Separate just because there doesn't seem to be a good way to test it otherwise.

Parameters
string$PHPSessionHandlingSee $wgPHPSessionHandling

Definition at line 69 of file PHPSessionHandler.php.

Referenced by MediaWiki\Session\PHPSessionHandler\__construct().

◆ setManager()

MediaWiki\Session\PHPSessionHandler::setManager ( SessionManager  $manager,
BagOStuff  $store,
LoggerInterface  $logger 
)

Set the manager, store, and logger.

Access:\n private Use self::install().
Parameters
SessionManager$manager
BagOStuff$store
LoggerInterface$logger

Definition at line 150 of file PHPSessionHandler.php.

References MediaWiki\Session\PHPSessionHandler\$logger, MediaWiki\Session\PHPSessionHandler\$manager, MediaWiki\Session\PHPSessionHandler\$store, and store.

◆ write()

MediaWiki\Session\PHPSessionHandler::write (   $id,
  $dataStr 
)

Write session data.

Access:\n private For internal use only
Parameters
string$idSession id
string$dataStrSession data. Not that you should ever call this directly, but note that this has the same issues with code injection via user-controlled data as does PHP's unserialize function.
Returns
bool|int Success (see self::returnSuccess())

Definition at line 256 of file PHPSessionHandler.php.

References $cache, $value, as, MediaWiki\Session\PHPSessionHandler\returnFailure(), MediaWiki\Session\PHPSessionHandler\returnSuccess(), and wfDeprecated().

Member Data Documentation

◆ $enable

bool MediaWiki\Session\PHPSessionHandler::$enable = false
protected

Whether PHP session handling is enabled.

Definition at line 39 of file PHPSessionHandler.php.

◆ $instance

PHPSessionHandler MediaWiki\Session\PHPSessionHandler::$instance = null
staticprotected

◆ $logger

LoggerInterface MediaWiki\Session\PHPSessionHandler::$logger
protected

◆ $manager

◆ $sessionFieldCache

array MediaWiki\Session\PHPSessionHandler::$sessionFieldCache = []
protected

Track original session fields for later modification check.

Definition at line 52 of file PHPSessionHandler.php.

◆ $store

BagOStuff null MediaWiki\Session\PHPSessionHandler::$store
protected

◆ $warn

MediaWiki\Session\PHPSessionHandler::$warn = true
protected

Definition at line 40 of file PHPSessionHandler.php.


The documentation for this class was generated from the following file: