* Use faster AlphabeticPager for Special:Categories
* (bug 8875) Show printable link in MonoBook sidebar for locally nonexistent
pages; perhaps useful for categories and shared images
+* Clean up session checks to better handle the case where the session was
+ opened during the current request. May help with some caching corner
+ cases.
== Languages updated ==
* Save master pos to the session and to memcached, if the session exists
*/
function saveMasterPos() {
- global $wgSessionStarted;
- if ( $wgSessionStarted && count( $this->mServers ) > 1 ) {
+ if ( session_id() != '' && count( $this->mServers ) > 1 ) {
# If this entire request was served from a slave without opening a connection to the
# master (however unlikely that may be), then we can fetch the position from the slave.
if ( empty( $this->mConnections[0] ) ) {
# maintain different caches for logged-in users and non-logged in ones
$wgRequest->response()->header( 'Vary: Accept-Encoding, Cookie' );
if( !$this->uncacheableBecauseRequestvars() && $this->mEnableClientCache ) {
- if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
+ if( $wgUseSquid && session_id() == '' &&
! $this->isPrintable() && $this->mSquidMaxage != 0 )
{
if ( $wgUseESI ) {
function __construct( &$article, $request = false ) {
global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType;
- global $wgUser;
$allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit');
$this->mArticle =& $article;
// Output may contain user-specific data; vary for open sessions
$this->mPrivateCache = ( $this->mSmaxage == 0 ) ||
- ( isset( $_COOKIE[ini_get( 'session.name' )] ) ||
- $wgUser->isLoggedIn() );
+ ( session_id() != '' );
if ( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) {
$this->mContentType = 'text/x-wiki';
if( !ini_get( 'session.auto_start' ) )
session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
-if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
+if( !$wgCommandLineMode && ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
wfIncrStats( 'request_with_session' );
wfSetupSession();
$wgSessionStarted = true;
return $subpages;
}
+ /**
+ * Returns true if the IP should be shown in the header
+ */
+ function showIPinHeader() {
+ global $wgShowIPinHeader;
+ return $wgShowIPinHeader && session_id() != '';
+ }
+
function nameAndLogin() {
- global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
+ global $wgUser, $wgTitle, $wgLang, $wgContLang;
$lo = $wgContLang->specialPage( 'Userlogout' );
$s = '';
if ( $wgUser->isAnon() ) {
- if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
+ if( $this->showIPinHeader() ) {
$n = wfGetIP();
$tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
* @private
*/
function buildPersonalUrls() {
- global $wgTitle, $wgShowIPinHeader;
+ global $wgTitle;
$fname = 'SkinTemplate::buildPersonalUrls';
$pageurl = $wgTitle->getLocalURL();
'active' => false
);
} else {
- if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
+ if( $this->showIPinHeader() ) {
$href = &$this->userpageUrlDetails['href'];
$personal_urls['anonuserpage'] = array(
'text' => $this->username,
return $personal_urls;
}
- /**
- * Returns true if the IP should be shown in the header
- */
- function showIPinHeader() {
- global $wgShowIPinHeader;
- return $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] );
- }
-
function tabAction( $title, $message, $selected, $query='', $checkEdit=false ) {
$classes = array();
if( $selected ) {
function wfSpecialUserlogin() {
global $wgCommandLineMode;
global $wgRequest;
- if( !$wgCommandLineMode && !isset( $_COOKIE[session_name()] ) ) {
+ if( session_id() == '' ) {
wfSetupSession();
}
}
/**
+ * Check if a session cookie is present.
+ *
+ * This will not pick up a cookie set during _this_ request, but is
+ * meant to ensure that the client is returning the cookie which was
+ * set on a previous pass through the system.
+ *
* @private
*/
function hasSessionCookie() {
- global $wgDisableCookieCheck;
- return ( $wgDisableCookieCheck ) ? true : ( isset( $_COOKIE[session_name()] ) );
+ global $wgDisableCookieCheck, $wgRequest;
+ return $wgDisableCookieCheck ? true : $wgRequest->checkSessionCookie();
}
/**
* Returns true if there is a session cookie set.
* This does not necessarily mean that the user is logged in!
*
+ * If you want to check for an open session, use session_id()
+ * instead; that will also tell you if the session was opened
+ * during the current request (in which case the cookie will
+ * be sent back to the client at the end of the script run).
+ *
* @return bool
*/
function checkSessionCookie() {
- return isset( $_COOKIE[ini_get('session.name')] );
+ return isset( $_COOKIE[session_name()] );
}
/**
showCreditsPage( $article );
break;
case 'submit':
- if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) {
+ if( session_id() == '' ) {
/* Send a cookie so anons get talk message notifications */
- User::SetupSession();
+ wfSetupSession();
}
/* Continue... */
case 'edit':