2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* This file gets included if $wgSessionsInMemcache is set in the config.
|
|
|
|
|
* It redirects session handling functions to store their data in memcached
|
|
|
|
|
* instead of the local filesystem. Depending on circumstances, it may also
|
|
|
|
|
* be necessary to change the cookie settings to work across hostnames.
|
|
|
|
|
* See: http://www.php.net/manual/en/function.session-set-save-handler.php
|
2004-09-03 23:00:01 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Cache
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Get a cache key for the given session id.
|
|
|
|
|
*
|
|
|
|
|
* @param $id String: session id
|
|
|
|
|
* @return String: cache key
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_key( $id ) {
|
2006-10-04 09:06:18 +00:00
|
|
|
return wfMemcKey( 'session', $id );
|
2003-11-12 10:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Callback when opening a session.
|
|
|
|
|
* NOP: $wgMemc should be set up already.
|
|
|
|
|
*
|
|
|
|
|
* @param $save_path String: path used to store session files, unused
|
|
|
|
|
* @param $session_name String: session name
|
|
|
|
|
* @return Boolean: success
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_open( $save_path, $session_name ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Callback when closing a session.
|
|
|
|
|
* NOP.
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean: success
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_close() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Callback when reading session data.
|
|
|
|
|
*
|
|
|
|
|
* @param $id String: session id
|
|
|
|
|
* @return Mixed: session data
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_read( $id ) {
|
|
|
|
|
global $wgMemc;
|
|
|
|
|
$data = $wgMemc->get( memsess_key( $id ) );
|
2004-08-22 17:24:50 +00:00
|
|
|
if( ! $data ) return '';
|
2003-11-12 10:21:28 +00:00
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Callback when writing session data.
|
|
|
|
|
*
|
|
|
|
|
* @param $id String: session id
|
|
|
|
|
* @param $data Mixed: session data
|
|
|
|
|
* @return Boolean: success
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_write( $id, $data ) {
|
|
|
|
|
global $wgMemc;
|
|
|
|
|
$wgMemc->set( memsess_key( $id ), $data, 3600 );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Callback to destroy a session when calling session_destroy().
|
|
|
|
|
*
|
|
|
|
|
* @param $id String: session id
|
|
|
|
|
* @return Boolean: success
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_destroy( $id ) {
|
|
|
|
|
global $wgMemc;
|
2010-08-20 21:20:18 +00:00
|
|
|
|
2003-11-12 10:21:28 +00:00
|
|
|
$wgMemc->delete( memsess_key( $id ) );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-20 21:20:18 +00:00
|
|
|
* Callback to execute garbage collection.
|
|
|
|
|
* NOP: Memcached performs garbage collection.
|
|
|
|
|
*
|
|
|
|
|
* @param $maxlifetime Integer: maximum session life time
|
|
|
|
|
* @return Boolean: success
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-11-12 10:21:28 +00:00
|
|
|
function memsess_gc( $maxlifetime ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-03 15:24:51 +00:00
|
|
|
function memsess_write_close() {
|
|
|
|
|
session_write_close();
|
|
|
|
|
}
|
|
|
|
|
|