| Index: branches/REL1_4/phase3/includes/User.php |
| — | — | @@ -61,6 +61,17 @@ |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| | 65 | + * Serialze sleep function, for better cache efficiency and avoidance of |
| | 66 | + * silly "incomplete type" errors when skins are cached |
| | 67 | + */ |
| | 68 | + function __sleep() { |
| | 69 | + return array( 'mId', 'mName', 'mPassword', 'mEmail', 'mNewtalk', |
| | 70 | + 'mRights', 'mOptions', 'mDataLoaded', 'mNewpassword', 'mBlockedby', |
| | 71 | + 'mBlockreason', 'mTouched', 'mToken', 'RealName', 'mHash' ); |
| | 72 | + } |
| | 73 | + |
| | 74 | + |
| | 75 | + /** |
| 65 | 76 | * Get username given an id. |
| 66 | 77 | * @param integer $id Database user id |
| 67 | 78 | * @return string Nickname of a user |
| — | — | @@ -997,7 +1008,10 @@ |
| 998 | 1009 | ); |
| 999 | 1010 | $dbw->set( 'user_rights', 'ur_rights', implode( ',', $this->mRights ), |
| 1000 | 1011 | 'ur_user='. $this->mId, $fname ); |
| 1001 | | - $wgMemc->delete( "$wgDBname:user:id:$this->mId" ); |
| | 1012 | + |
| | 1013 | + if ( $wgMemc->set( "$wgDBname:user:id:{$this->mId}", $this, 86400 ) ) { |
| | 1014 | + wfDebug( "Saved user settings into cache\n" ); |
| | 1015 | + } |
| 1002 | 1016 | } |
| 1003 | 1017 | |
| 1004 | 1018 | /** |
| — | — | @@ -1013,7 +1027,7 @@ |
| 1014 | 1028 | if ($this->getID() != 0) { |
| 1015 | 1029 | $field = 'user_id'; |
| 1016 | 1030 | $value = $this->getID(); |
| 1017 | | - $key = "$wgDBname:user:id:$this->mId"; |
| | 1031 | + $key = false; |
| 1018 | 1032 | } else { |
| 1019 | 1033 | $field = 'user_ip'; |
| 1020 | 1034 | $value = $this->mName; |
| — | — | @@ -1029,10 +1043,14 @@ |
| 1030 | 1044 | $changed = true; |
| 1031 | 1045 | if ($res !== false && $this->mNewtalk == 0) { |
| 1032 | 1046 | $dbw->delete('user_newtalk', array($field => $value), $fname); |
| 1033 | | - $wgMemc->delete($key); |
| | 1047 | + if ( $key ) { |
| | 1048 | + $wgMemc->set( $key, 0 ); |
| | 1049 | + } |
| 1034 | 1050 | } else if ($res === false && $this->mNewtalk == 1) { |
| 1035 | 1051 | $dbw->insert('user_newtalk', array($field => $value), $fname); |
| 1036 | | - $wgMemc->delete($key); |
| | 1052 | + if ( $key ) { |
| | 1053 | + $wgMemc->set( $key, 1 ); |
| | 1054 | + } |
| 1037 | 1055 | } else { |
| 1038 | 1056 | $changed = false; |
| 1039 | 1057 | } |
| — | — | @@ -1043,6 +1061,7 @@ |
| 1044 | 1062 | /*SET*/ array( 'user_touched' => $this->mTouched ), |
| 1045 | 1063 | /*WHERE*/ array( 'user_id' => $this->getID() ), |
| 1046 | 1064 | $fname); |
| | 1065 | + $wgMemc->set( "$wgDBname:user:id:{$this->mId}", $this, 86400 ); |
| 1047 | 1066 | } |
| 1048 | 1067 | } |
| 1049 | 1068 | |