r114773 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114772‎ | r114773 | r114774 >
Date:20:53, 6 April 2012
Author:bsitu
Status:deferred
Tags:
Comment:
Update the logic for PageTriage filtering
Modified paths:
  • /trunk/extensions/PageTriage/api/ApiPageTriageList.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/api/ApiPageTriageList.php
@@ -55,19 +55,16 @@
5656 }
5757
5858 // Start building the massive filter which includes meta data
59 - $tagConds = self::buildTagQuery( $opts );
6059 $tables = array( 'pagetriage_page', 'page' );
6160 $conds = array( 'ptrp_page_id = page_id' );
6261
63 - // Show reviewed
64 - if ( $opts['showreviewed'] ) {
65 - $conds['ptrp_reviewed'] = array( 0, 1 );
66 - } else {
 62+ // Include reviewed
 63+ if ( !$opts['showreviewed'] ) {
6764 $conds['ptrp_reviewed'] = 0;
6865 }
69 - // Show redirect
70 - if ( $opts['showredirs'] ) {
71 - $conds['page_is_redirect'] = 1;
 66+ // Include redirect
 67+ if ( !$opts['showredirs'] ) {
 68+ $conds['page_is_redirect'] = 0;
7269 }
7370 // Show by namespace
7471 if ( array_key_exists( 'namespace', $opts ) ) {
@@ -78,10 +75,9 @@
7976 $conds[] = 'ptrp_timestamp' . $offsetOperator . $opts['offset'];
8077 }
8178
 79+ $tagConds = self::buildTagQuery( $opts );
8280 if ( $tagConds ) {
83 - $conds[] = '(' . implode( ' OR ', $tagConds ) . ') AND ptrpt_page_id = ptrp_page_id';
84 - $options['GROUP BY'] = 'ptrpt_page_id';
85 - $options['HAVING'] = 'COUNT(ptrpt_tag_id) = ' . count( $tagConds );
 81+ $conds[] = $tagConds;
8682 $tables[] = 'pagetriage_page_tags';
8783 }
8884
@@ -106,9 +102,10 @@
107103 }
108104
109105 private static function buildTagQuery( $opts ) {
110 - $tagConds = array();
 106+ $dbr = wfGetDB( DB_SLAVE );
 107+ $tagConds = '';
111108
112 - $searchableTags = array(
 109+ $searchableTags = array(
113110 // no categories assigned
114111 'no_category' => array( 'name' => 'category_count', 'op' => '=', 'val' => '0' ),
115112 // no inbound links
@@ -117,15 +114,20 @@
118115 'non_autoconfirmed_users' => array( 'name' => 'user_autoconfirmed', 'op' => '=', 'val' => '0' ),
119116 // blocked users
120117 'blocked_users' => array( 'name' => 'user_block_status', 'op' => '=', 'val' => '1' ),
121 - // show bots
122 - 'showbots' => array( 'name' => 'user_bot', 'op' => '=', 'val' => '1' )
 118+ // bots
 119+ 'showbots' => array( 'name' => 'user_bot', 'op' => '=', 'val' => '1' ),
 120+ // user name
 121+ 'username' => array( 'name' => 'user_name', 'op' => '=', 'val' => $opts['username'] )
123122 );
124123
125124 $tags = ArticleMetadata::getValidTags();
126125
 126+ // only single tag search is allowed
127127 foreach ( $searchableTags as $key => $val ) {
128128 if ( $opts[$key] ) {
129 - $tagConds[] = " ( ptrpt_tag_id = '" . $tags[$val['name']] . "' AND ptrpt_value " . $val['op'] . " " . $val['val'] . " ) ";
 129+ $tagConds = " ptrpt_page_id = ptrp_page_id AND ptrpt_tag_id = '" . $tags[$val['name']] . "' AND
 130+ ptrpt_value " . $val['op'] . " " . $dbr->addQuotes( $val['val'] );
 131+ break;
130132 }
131133 }
132134
@@ -171,7 +173,9 @@
172174 'blocked_users' => array(
173175 ApiBase::PARAM_TYPE => 'boolean',
174176 ),
175 -
 177+ 'username' => array(
 178+ ApiBase::PARAM_TYPE => 'user',
 179+ ),
176180 );
177181 }
178182
@@ -187,7 +191,8 @@
188192 'no_category' => 'Whether to show only pages with no category',
189193 'no_inbound_links' => 'Whether to show only pages with no inbound links',
190194 'non_autoconfirmed_users' => 'Whether to show only pages created by non auto confirmed users',
191 - 'blocked_users' => 'Whether to show only pages created by blocked users'
 195+ 'blocked_users' => 'Whether to show only pages created by blocked users',
 196+ 'username' => 'Show only pages created by username',
192197 );
193198 }
194199

Status & tagging log