r56710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56709‎ | r56710 | r56711 >
Date:15:56, 21 September 2009
Author:werdna
Status:deferred
Tags:
Comment:
Change user signature caching to be per-username, not per-uid. Per-UID breaks for anonymous users
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1197,16 +1197,19 @@
11981198 function getSignature( $user ) {
11991199 if ( is_object($user) ) {
12001200 $uid = $user->getId();
 1201+ $name = $user->getName();
12011202 } elseif ( is_integer($user) ) {
12021203 $uid = $user;
1203 - $user = null;
 1204+ $user = User::newFromId($uid);
 1205+ $name = $user->getName();
12041206 } else {
12051207 $user = User::newFromName( $user );
 1208+ $name = $user->getName();
12061209 $uid = $user->getId();
12071210 }
12081211
1209 - if ( isset( self::$userSignatureCache[$uid] ) ) {
1210 - return self::$userSignatureCache[$uid];
 1212+ if ( isset( self::$userSignatureCache[$name] ) ) {
 1213+ return self::$userSignatureCache[$name];
12111214 }
12121215
12131216 if (!$user) {
@@ -1218,7 +1221,7 @@
12191222 $sig = $wgParser->getUserSig( $user );
12201223 $sig = $wgOut->parseInline( $sig );
12211224
1222 - self::$userSignatureCache[$uid] = $sig;
 1225+ self::$userSignatureCache[$name] = $sig;
12231226
12241227 return $sig;
12251228 }
Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -487,6 +487,7 @@
488488
489489 foreach( $userIds as $uid ) {
490490 $user = User::newFromId($uid); // Should pull from UID cache.
 491+ $name = $user->getName();
491492
492493 // Grab sig data
493494 $nickname = null;
@@ -503,7 +504,7 @@
504505 $sig = $wgOut->parseInline( $sig );
505506
506507 // Save into LqtView for later use.
507 - LqtView::$userSignatureCache[$uid] = $sig;
 508+ LqtView::$userSignatureCache[$name] = $sig;
508509 }
509510 }
510511

Status & tagging log