From a0f8d5c6eaef5728cc86d96cdd9a0273f9655484 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 10 Apr 2009 14:53:32 +0000 Subject: [PATCH] (bugs 11381, 11613) Session.save_handler issues: * Added a new config variable, $wgSessionHandler to control what value the save_handler is set to * Setting to null allows you to disable setting it entirely, which was the primary complaint of the two bugs, but it also allows you to set it to whatever you'd like --- RELEASE-NOTES | 3 +++ includes/DefaultSettings.php | 6 ++++++ includes/GlobalFunctions.php | 11 ++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0c5f2a7823..b9dd86affb 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -31,6 +31,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Add $wgExportFromNamespaces for enabling/disabling the "export all from namespace" option (disabled by default) * (bug 18222) $wgMinimalPasswordLength default is now 1 +* $wgSessionHandler can be used to configure session.save_handler === New features in 1.15 === @@ -335,6 +336,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 12998) Allow , , etc. in DISPLAYTITLE * (bug 1553) Lowercase navigation headings in German * (bug 7830) Pending transactions failed to commit on loginToUse() error +* (bug 11613) session.save_handler being over-ridden +* (bug 11381) session.save_handler being set twice (causes error) == API changes in 1.15 == * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8fd45085b0..74f5d5cd40 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -736,6 +736,12 @@ $wgParserCacheExpireTime = 86400; $wgSessionsInMemcached = false; +/** 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 + * 'session_mysql.' Setting to null skips setting this entirely (which might be + * useful if you're doing cross-application sessions, see bug 11381) */ +$wgSessionHandler = 'files'; + /**@{ * Memcached-specific settings * See docs/memcached.txt diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4668652955..2ca81c9c5f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2708,13 +2708,14 @@ function wfHttpOnlySafe() { * Initialise php session */ function wfSetupSession() { - global $wgSessionsInMemcached, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly; + global $wgSessionsInMemcached, $wgCookiePath, $wgCookieDomain, + $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler; if( $wgSessionsInMemcached ) { require_once( 'MemcachedSessions.php' ); - } elseif( 'files' != ini_get( 'session.save_handler' ) ) { - # If it's left on 'user' or another setting from another - # application, it will end up failing. Try to recover. - ini_set ( 'session.save_handler', 'files' ); + } elseif( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) { + # Only set this if $wgSessionHandler isn't null and session.save_handler + # hasn't already been set to the desired value (that causes errors) + ini_set ( 'session.save_handler', $wgSessionHandler ); } $httpOnlySafe = wfHttpOnlySafe(); wfDebugLog( 'cookie', -- 2.20.1