MediaWiki r9404 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r9403‎ | r9404 (on ViewVC)‎ | r9405 >
Date:18:12, 12 June 2005
Author:timstarling
Status:old
Tags:
Comment:
Attempting to fix user_newtalk problem on the live site by clearing the cache properly, although I can't actually reproduce the problem in my test installation so I don't know if this will fix it. Also changed deletes to sets, which is generally useful to avoid problems with replication lag.
Modified paths:

Diff [purge]

Index: branches/REL1_4/phase3/includes/User.php
@@ -61,6 +61,17 @@
6262 }
6363
6464 /**
 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+ /**
6576 * Get username given an id.
6677 * @param integer $id Database user id
6778 * @return string Nickname of a user
@@ -997,7 +1008,10 @@
9981009 );
9991010 $dbw->set( 'user_rights', 'ur_rights', implode( ',', $this->mRights ),
10001011 '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+ }
10021016 }
10031017
10041018 /**
@@ -1013,7 +1027,7 @@
10141028 if ($this->getID() != 0) {
10151029 $field = 'user_id';
10161030 $value = $this->getID();
1017 - $key = "$wgDBname:user:id:$this->mId";
 1031+ $key = false;
10181032 } else {
10191033 $field = 'user_ip';
10201034 $value = $this->mName;
@@ -1029,10 +1043,14 @@
10301044 $changed = true;
10311045 if ($res !== false && $this->mNewtalk == 0) {
10321046 $dbw->delete('user_newtalk', array($field => $value), $fname);
1033 - $wgMemc->delete($key);
 1047+ if ( $key ) {
 1048+ $wgMemc->set( $key, 0 );
 1049+ }
10341050 } else if ($res === false && $this->mNewtalk == 1) {
10351051 $dbw->insert('user_newtalk', array($field => $value), $fname);
1036 - $wgMemc->delete($key);
 1052+ if ( $key ) {
 1053+ $wgMemc->set( $key, 1 );
 1054+ }
10371055 } else {
10381056 $changed = false;
10391057 }
@@ -1043,6 +1061,7 @@
10441062 /*SET*/ array( 'user_touched' => $this->mTouched ),
10451063 /*WHERE*/ array( 'user_id' => $this->getID() ),
10461064 $fname);
 1065+ $wgMemc->set( "$wgDBname:user:id:{$this->mId}", $this, 86400 );
10471066 }
10481067 }
10491068

Status & tagging log

  • 01:56, 13 October 2010 ^demon (Talk | contribs) changed the status of r9404 [removed: new added: old]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox