MediaWiki  1.23.2
ObjectCacheSessionHandler.php
Go to the documentation of this file.
1 <?php
34  static function install() {
35  session_set_save_handler(
36  array( __CLASS__, 'open' ),
37  array( __CLASS__, 'close' ),
38  array( __CLASS__, 'read' ),
39  array( __CLASS__, 'write' ),
40  array( __CLASS__, 'destroy' ),
41  array( __CLASS__, 'gc' ) );
42 
43  // It's necessary to register a shutdown function to call session_write_close(),
44  // because by the time the request shutdown function for the session module is
45  // called, $wgMemc has already been destroyed. Shutdown functions registered
46  // this way are called before object destruction.
47  register_shutdown_function( array( __CLASS__, 'handleShutdown' ) );
48  }
49 
53  static function getCache() {
54  global $wgSessionCacheType;
55  return ObjectCache::getInstance( $wgSessionCacheType );
56  }
57 
64  static function getKey( $id ) {
65  return wfMemcKey( 'session', $id );
66  }
67 
75  static function open( $save_path, $session_name ) {
76  return true;
77  }
78 
85  static function close() {
86  return true;
87  }
88 
95  static function read( $id ) {
96  $data = self::getCache()->get( self::getKey( $id ) );
97  if ( $data === false ) {
98  return '';
99  }
100  return $data;
101  }
102 
110  static function write( $id, $data ) {
111  global $wgObjectCacheSessionExpiry;
112  self::getCache()->set( self::getKey( $id ), $data, $wgObjectCacheSessionExpiry );
113  return true;
114  }
115 
122  static function destroy( $id ) {
123  self::getCache()->delete( self::getKey( $id ) );
124  return true;
125  }
126 
134  static function gc( $maxlifetime ) {
135  return true;
136  }
137 
142  static function handleShutdown() {
143  session_write_close();
144  }
145 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ObjectCacheSessionHandler\open
static open( $save_path, $session_name)
Callback when opening a session.
Definition: ObjectCacheSessionHandler.php:75
ObjectCacheSessionHandler\destroy
static destroy( $id)
Callback to destroy a session when calling session_destroy().
Definition: ObjectCacheSessionHandler.php:122
ObjectCacheSessionHandler\write
static write( $id, $data)
Callback when writing session data.
Definition: ObjectCacheSessionHandler.php:110
ObjectCacheSessionHandler\close
static close()
Callback when closing a session.
Definition: ObjectCacheSessionHandler.php:85
ObjectCacheSessionHandler\gc
static gc( $maxlifetime)
Callback to execute garbage collection.
Definition: ObjectCacheSessionHandler.php:134
wfMemcKey
wfMemcKey()
Get a cache key.
Definition: GlobalFunctions.php:3571
ObjectCache\getInstance
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:39
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
ObjectCacheSessionHandler\read
static read( $id)
Callback when reading session data.
Definition: ObjectCacheSessionHandler.php:95
ObjectCacheSessionHandler\install
static install()
Install a session handler for the current web request.
Definition: ObjectCacheSessionHandler.php:34
ObjectCacheSessionHandler\handleShutdown
static handleShutdown()
Shutdown function.
Definition: ObjectCacheSessionHandler.php:142
ObjectCacheSessionHandler\getKey
static getKey( $id)
Get a cache key for the given session id.
Definition: ObjectCacheSessionHandler.php:64
ObjectCacheSessionHandler
Session storage in object cache.
Definition: ObjectCacheSessionHandler.php:30
ObjectCacheSessionHandler\getCache
static getCache()
Get the cache storage object to use for session storage.
Definition: ObjectCacheSessionHandler.php:53