From 3b0132a64923ac8f64f072d6a9e5a02e89b44e10 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 8 Aug 2012 11:20:30 +1000 Subject: [PATCH] Allow session expiry time to be configured When $wgSessionsInObjectCache is enabled, use a configurable expiry time instead of a hard-coded one-hour expiry. Change-Id: Ia51962176d30fd87e298c47ec347a143cad80772 --- RELEASE-NOTES-1.20 | 3 ++- includes/DefaultSettings.php | 6 ++++++ includes/objectcache/ObjectCacheSessionHandler.php | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index c52ff60970..92e1e765aa 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -111,7 +111,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * Session storage can now configured independently of general object cache storage, by using $wgSessionCacheType. $wgSessionsInMemcached has been renamed to $wgSessionsInObjectCache, with the old name retained for backwards - compatibility. + compatibility. When this feature is enabled, the expiry time can now be + configured with $wgObjectCacheSessionExpiry. * Implemented mw.user.getGroups for getting and caching user groups. * (bug 37830) Added $wgRequirePasswordforEmailChange to control whether password confirmation is required for changing an email address or not. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index dda191e4f1..55126e7695 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1735,6 +1735,12 @@ $wgSessionsInMemcached = false; */ $wgSessionsInObjectCache = false; +/** + * The expiry time to use for session storage when $wgSessionsInObjectCache is + * enabled, in seconds. + */ +$wgObjectCacheSessionExpiry = 3600; + /** * This is used for setting php's session.save_handler. In practice, you will * almost never need to change this ever. Other options might be 'user' or diff --git a/includes/objectcache/ObjectCacheSessionHandler.php b/includes/objectcache/ObjectCacheSessionHandler.php index 3dcfa9f690..e6c68818a4 100644 --- a/includes/objectcache/ObjectCacheSessionHandler.php +++ b/includes/objectcache/ObjectCacheSessionHandler.php @@ -101,7 +101,8 @@ class ObjectCacheSessionHandler { * @return Boolean: success */ static function write( $id, $data ) { - self::getCache()->set( self::getKey( $id ), $data, 3600 ); + global $wgObjectCacheSessionExpiry; + self::getCache()->set( self::getKey( $id ), $data, $wgObjectCacheSessionExpiry ); return true; } -- 2.20.1