From 65a6465cd461b17e77817b86a7e137a6754a74d5 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 29 May 2008 07:50:27 +0000 Subject: [PATCH] * Fix CentralAuth logout, was mostly broken. * Allow the image returned by Special:AutoLogin to be customised. Feature in progress. --- includes/User.php | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/includes/User.php b/includes/User.php index 050b3d5e61..77dce0b7c1 100644 --- a/includes/User.php +++ b/includes/User.php @@ -747,6 +747,8 @@ class User { $this->mRegistration = wfTimestamp( TS_MW ); $this->mGroups = array(); + wfRunHooks( 'UserLoadDefaults', array( $this, $name ) ); + wfProfileOut( __METHOD__ ); } @@ -2122,19 +2124,29 @@ class User { function setCookies() { $this->load(); if ( 0 == $this->mId ) return; - - $_SESSION['wsUserID'] = $this->mId; - - $this->setCookie( 'UserID', $this->mId ); - $this->setCookie( 'UserName', $this->getName() ); - - $_SESSION['wsUserName'] = $this->getName(); - - $_SESSION['wsToken'] = $this->mToken; + $session = array( + 'wsUserID' => $this->mId, + 'wsToken' => $this->mToken, + 'wsUserName' => $this->getName() + ); + $cookies = array( + 'UserID' => $this->mId, + 'UserName' => $this->getName(), + ); if ( 1 == $this->getOption( 'rememberpassword' ) ) { - $this->setCookie( 'Token', $this->mToken ); + $cookies['Token'] = $this->mToken; } else { - $this->clearCookie( 'Token' ); + $cookies['Token'] = false; + } + + wfRunHooks( 'UserSetCookies', array( $this, &$session, &$cookies ) ); + $_SESSION = $session + $_SESSION; + foreach ( $cookies as $name => $value ) { + if ( $value === false ) { + $this->clearCookie( $name ); + } else { + $this->setCookie( $name, $value ); + } } } -- 2.20.1