r32996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32995‎ | r32996 | r32997 >
Date:23:30, 8 April 2008
Author:aaron
Status:old
Tags:
Comment:
* Fix user param
* Fix sync errors
* Use red contribs links if needed
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -843,9 +843,10 @@
844844 * @param string $userText User name or IP address
845845 * @param bool $redContribsWhenNoEdits Should the contributions link be red if the user has no edits?
846846 * @param int $flags Customisation flags (e.g. self::TOOL_LINKS_NOBLOCK)
 847+ * @param int $edits, user edit count (optional, for performance)
847848 * @return string
848849 */
849 - public function userToolLinks( $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0 ) {
 850+ public function userToolLinks( $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits=null ) {
850851 global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans;
851852 $talkable = !( $wgDisableAnonTalk && 0 == $userId );
852853 $blockable = ( $wgSysopUserBans || 0 == $userId ) && !$flags & self::TOOL_LINKS_NOBLOCK;
@@ -856,7 +857,8 @@
857858 }
858859 if( $userId ) {
859860 // check if the user has an edit
860 - if( $redContribsWhenNoEdits && User::edits( $userId ) == 0 ) {
 861+ $count = !is_null($edits) ? $edits : User::edits( $userId );
 862+ if( $redContribsWhenNoEdits && $count == 0 ) {
861863 $style = " class='new'";
862864 } else {
863865 $style = '';
Index: trunk/phase3/includes/LogEventsList.php
@@ -160,7 +160,7 @@
161161 $userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
162162 } else {
163163 $userLink = $this->skin->userLink( $row->log_user, $row->user_name ) .
164 - $this->skin->userToolLinks( $row->log_user, $row->user_name );
 164+ $this->skin->userToolLinks( $row->log_user, $row->user_name, true, 0, $row->user_editcount );
165165 }
166166 // Comment
167167 if( self::isDeleted($row,LogPage::DELETED_COMMENT) ) {
@@ -432,7 +432,7 @@
433433 return false;
434434 }
435435 /* Fetch userid at first, if known, provides awesome query plan afterwards */
436 - $userid = User::idFromName( $this->user );
 436+ $userid = User::idFromName( $name );
437437 if( !$userid ) {
438438 /* It should be nicer to abort query at all,
439439 but for now it won't pass anywhere behind the optimizer */
@@ -485,8 +485,8 @@
486486 }
487487 return array(
488488 'tables' => array( 'logging', 'user' ),
489 - 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title',
490 - 'log_params', 'log_comment', $log_id, 'log_deleted', 'log_timestamp', 'user_name' ),
 489+ 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params',
 490+ 'log_comment', $log_id, 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ),
491491 'conds' => $this->mConds,
492492 'options' => $index
493493 );
@@ -499,14 +499,16 @@
500500 function getStartBody() {
501501 wfProfileIn( __METHOD__ );
502502 # Do a link batch query
503 - $lb = new LinkBatch;
504 - while( $row = $this->mResult->fetchObject() ) {
505 - $lb->add( $row->log_namespace, $row->log_title );
506 - $lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
507 - $lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
 503+ if( $this->getNumRows() > 0 ) {
 504+ $lb = new LinkBatch;
 505+ while( $row = $this->mResult->fetchObject() ) {
 506+ $lb->add( $row->log_namespace, $row->log_title );
 507+ $lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
 508+ $lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
 509+ }
 510+ $lb->execute();
 511+ $this->mResult->seek( 0 );
508512 }
509 - $lb->execute();
510 - $this->mResult->seek( 0 );
511513 wfProfileOut( __METHOD__ );
512514 return '';
513515 }

Status & tagging log