From: Fran Rogers Date: Sat, 13 Sep 2008 05:48:11 +0000 (+0000) Subject: #15577: Moved spreading of autoblocks from User::isBlocked() et al to ::setCookies... X-Git-Tag: 1.31.0-rc.0~45338 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=48f283a1ae331e8ebf9f43580d7bc9be3df09469;p=lhc%2Fweb%2Fwiklou.git #15577: Moved spreading of autoblocks from User::isBlocked() et al to ::setCookies() and (if the session doesn't exist, but token cookie does) ::loadFromSession(). Autoblocks will now be spread predictably at the beginning of a session, instead of at random points as a side effect of testing for blocks. --- diff --git a/includes/User.php b/includes/User.php index bc4b13192c..b7819e5c78 100644 --- a/includes/User.php +++ b/includes/User.php @@ -834,6 +834,11 @@ class User { } else if ( isset( $_COOKIE["{$wgCookiePrefix}Token"] ) ) { $passwordCorrect = $this->mToken == $_COOKIE["{$wgCookiePrefix}Token"]; $from = 'cookie'; + + if ( ( $sName == $this->mName ) && $passwordCorrect ) { + # New session from old cookie - spread any applicable autoblocks + $this->spreadBlock(); + } } else { # No session or persistent login cookie $this->loadDefaults(); @@ -1049,9 +1054,6 @@ class User { $this->mBlockedby = $this->mBlock->mBy; $this->mBlockreason = $this->mBlock->mReason; $this->mHideName = $this->mBlock->mHideName; - if ( $this->isLoggedIn() ) { - $this->spreadBlock(); - } } else { $this->mBlock = null; wfDebug( __METHOD__.": No block.\n" ); @@ -2236,6 +2238,9 @@ class User { } else { $cookies['Token'] = false; } + + # Spread any applicable autoblocks + $this->spreadBlock(); wfRunHooks( 'UserSetCookies', array( $this, &$session, &$cookies ) ); $_SESSION = $session + $_SESSION;