Index: trunk/phase3/includes/User.php |
— | — | @@ -119,8 +119,7 @@ |
120 | 120 | // user_group table |
121 | 121 | 'mGroups', |
122 | 122 | // user_properties table |
123 | | - 'mOptions', |
124 | | - 'mOptionsLoaded', |
| 123 | + 'mOptionOverrides', |
125 | 124 | ); |
126 | 125 | |
127 | 126 | /** |
— | — | @@ -189,8 +188,8 @@ |
190 | 189 | /** @name Cache variables */ |
191 | 190 | //@{ |
192 | 191 | var $mId, $mName, $mRealName, $mPassword, $mNewpassword, $mNewpassTime, |
193 | | - $mEmail, $mOptions, $mTouched, $mToken, $mEmailAuthenticated, |
194 | | - $mEmailToken, $mEmailTokenExpires, $mRegistration, $mGroups; |
| 192 | + $mEmail, $mTouched, $mToken, $mEmailAuthenticated, |
| 193 | + $mEmailToken, $mEmailTokenExpires, $mRegistration, $mGroups, $mOptionOverrides; |
195 | 194 | //@} |
196 | 195 | |
197 | 196 | /** |
— | — | @@ -213,7 +212,7 @@ |
214 | 213 | //@{ |
215 | 214 | var $mNewtalk, $mDatePreference, $mBlockedby, $mHash, $mSkin, $mRights, |
216 | 215 | $mBlockreason, $mBlock, $mEffectiveGroups, $mBlockedGlobally, |
217 | | - $mLocked, $mHideName; |
| 216 | + $mLocked, $mHideName, $mOptions; |
218 | 217 | //@} |
219 | 218 | |
220 | 219 | /** |
— | — | @@ -283,7 +282,7 @@ |
284 | 283 | # Try cache |
285 | 284 | $key = wfMemcKey( 'user', 'id', $this->mId ); |
286 | 285 | $data = $wgMemc->get( $key ); |
287 | | - if ( !is_array( $data ) || $data['mVersion'] < MW_USER_VERSION ) { |
| 286 | + if ( !is_array( $data ) || $data['mVersion'] < 'MW_USER_VERSION' ) { |
288 | 287 | # Object is expired, load from DB |
289 | 288 | $data = false; |
290 | 289 | } |
— | — | @@ -773,7 +772,8 @@ |
774 | 773 | $this->mPassword = $this->mNewpassword = ''; |
775 | 774 | $this->mNewpassTime = null; |
776 | 775 | $this->mEmail = ''; |
777 | | - $this->mOptions = null; # Defer init |
| 776 | + $this->mOptionOverrides = null; |
| 777 | + $this->mOptionsLoaded = false; |
778 | 778 | |
779 | 779 | if ( isset( $_COOKIE[$wgCookiePrefix.'LoggedOut'] ) ) { |
780 | 780 | $this->mTouched = wfTimestamp( TS_MW, $_COOKIE[$wgCookiePrefix.'LoggedOut'] ); |
— | — | @@ -972,6 +972,7 @@ |
973 | 973 | $this->mSkin = null; |
974 | 974 | $this->mRights = null; |
975 | 975 | $this->mEffectiveGroups = null; |
| 976 | + $this->mOptions = array(); |
976 | 977 | |
977 | 978 | if ( $reloadFrom ) { |
978 | 979 | $this->mDataLoaded = false; |
— | — | @@ -2297,10 +2298,11 @@ |
2298 | 2299 | * @private |
2299 | 2300 | */ |
2300 | 2301 | function decodeOptions( $str ) { |
2301 | | - if ($str) |
2302 | | - $this->mOptionsLoaded = true; |
2303 | | - else |
| 2302 | + if (!$str) |
2304 | 2303 | return; |
| 2304 | + |
| 2305 | + $this->mOptionsLoaded = true; |
| 2306 | + $this->mOptionOverrides = array(); |
2305 | 2307 | |
2306 | 2308 | $this->mOptions = array(); |
2307 | 2309 | $a = explode( "\n", $str ); |
— | — | @@ -2308,6 +2310,7 @@ |
2309 | 2311 | $m = array(); |
2310 | 2312 | if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) { |
2311 | 2313 | $this->mOptions[$m[1]] = $m[2]; |
| 2314 | + $this->mOptionOverrides[$m[1]] = $m[2]; |
2312 | 2315 | } |
2313 | 2316 | } |
2314 | 2317 | } |
— | — | @@ -3513,18 +3516,29 @@ |
3514 | 3517 | return; |
3515 | 3518 | |
3516 | 3519 | $this->mOptions = self::getDefaultOptions(); |
3517 | | - |
3518 | | - // Load from database |
3519 | | - $dbr = wfGetDB( DB_SLAVE ); |
3520 | 3520 | |
3521 | | - $res = $dbr->select( 'user_properties', |
3522 | | - '*', |
3523 | | - array('up_user' => $this->getId()), |
3524 | | - __METHOD__ |
3525 | | - ); |
| 3521 | + // Maybe load from the object |
3526 | 3522 | |
3527 | | - while( $row = $dbr->fetchObject( $res ) ) { |
3528 | | - $this->mOptions[$row->up_property] = $row->up_value; |
| 3523 | + if ( !is_null($this->mOptionOverrides) ) { |
| 3524 | + wfDebug( "Loading options for user ".$this->getId()." from override cache.\n" ); |
| 3525 | + foreach( $this->mOptionOverrides as $key => $value ) { |
| 3526 | + $this->mOptions[$key] = $value; |
| 3527 | + } |
| 3528 | + } else { |
| 3529 | + wfDebug( "Loading options for user ".$this->getId()." from database.\n" ); |
| 3530 | + // Load from database |
| 3531 | + $dbr = wfGetDB( DB_SLAVE ); |
| 3532 | + |
| 3533 | + $res = $dbr->select( 'user_properties', |
| 3534 | + '*', |
| 3535 | + array('up_user' => $this->getId()), |
| 3536 | + __METHOD__ |
| 3537 | + ); |
| 3538 | + |
| 3539 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 3540 | + $this->mOptionOverrides[$row->up_property] = $row->up_value; |
| 3541 | + $this->mOptions[$row->up_property] = $row->up_value; |
| 3542 | + } |
3529 | 3543 | } |
3530 | 3544 | |
3531 | 3545 | $this->mOptionsLoaded = true; |