r40715 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40714‎ | r40715 | r40716 >
Date:21:30, 10 September 2008
Author:aaron
Status:old
Tags:
Comment:
Exclude bot edits from Special:Contributions/newbies (bug 15554)
Modified paths:
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -34,17 +34,18 @@
3535 }
3636
3737 function getQueryInfo() {
38 - list( $index, $userCond ) = $this->getUserCond();
 38+ list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
3939 $conds = array_merge( array('page_id=rev_page'), $userCond, $this->getNamespaceCond() );
4040 $queryInfo = array(
41 - 'tables' => array( 'page', 'revision' ),
 41+ 'tables' => $tables,
4242 'fields' => array(
4343 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'rev_id', 'rev_page',
4444 'rev_text_id', 'rev_timestamp', 'rev_comment', 'rev_minor_edit', 'rev_user',
4545 'rev_user_text', 'rev_parent_id', 'rev_deleted'
4646 ),
4747 'conds' => $conds,
48 - 'options' => array( 'USE INDEX' => array('revision' => $index) )
 48+ 'options' => array( 'USE INDEX' => array('revision' => $index) ),
 49+ 'join_conds' => $join_cond
4950 );
5051 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
5152 return $queryInfo;
@@ -52,16 +53,21 @@
5354
5455 function getUserCond() {
5556 $condition = array();
56 -
 57+ $join_conds = array();
5758 if ( $this->target == 'newbies' ) {
 59+ $tables = array( 'user_groups', 'page', 'revision' );
5860 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
5961 $condition[] = 'rev_user >' . (int)($max - $max / 100);
 62+ $condition[] = 'ug_group IS NULL';
6063 $index = 'user_timestamp';
 64+ # FIXME: other groups may have 'bot' rights
 65+ $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
6166 } else {
 67+ $tables = array( 'page', 'revision' );
6268 $condition['rev_user_text'] = $this->target;
6369 $index = 'usertext_timestamp';
6470 }
65 - return array( $index, $condition );
 71+ return array( $tables, $index, $condition, $join_conds );
6672 }
6773
6874 function getNamespaceCond() {