Index: trunk/extensions/PageTriage/api/ApiPageTriageList.php |
— | — | @@ -55,19 +55,16 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Start building the massive filter which includes meta data |
59 | | - $tagConds = self::buildTagQuery( $opts ); |
60 | 59 | $tables = array( 'pagetriage_page', 'page' ); |
61 | 60 | $conds = array( 'ptrp_page_id = page_id' ); |
62 | 61 | |
63 | | - // Show reviewed |
64 | | - if ( $opts['showreviewed'] ) { |
65 | | - $conds['ptrp_reviewed'] = array( 0, 1 ); |
66 | | - } else { |
| 62 | + // Include reviewed |
| 63 | + if ( !$opts['showreviewed'] ) { |
67 | 64 | $conds['ptrp_reviewed'] = 0; |
68 | 65 | } |
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; |
72 | 69 | } |
73 | 70 | // Show by namespace |
74 | 71 | if ( array_key_exists( 'namespace', $opts ) ) { |
— | — | @@ -78,10 +75,9 @@ |
79 | 76 | $conds[] = 'ptrp_timestamp' . $offsetOperator . $opts['offset']; |
80 | 77 | } |
81 | 78 | |
| 79 | + $tagConds = self::buildTagQuery( $opts ); |
82 | 80 | 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; |
86 | 82 | $tables[] = 'pagetriage_page_tags'; |
87 | 83 | } |
88 | 84 | |
— | — | @@ -106,9 +102,10 @@ |
107 | 103 | } |
108 | 104 | |
109 | 105 | private static function buildTagQuery( $opts ) { |
110 | | - $tagConds = array(); |
| 106 | + $dbr = wfGetDB( DB_SLAVE ); |
| 107 | + $tagConds = ''; |
111 | 108 | |
112 | | - $searchableTags = array( |
| 109 | + $searchableTags = array( |
113 | 110 | // no categories assigned |
114 | 111 | 'no_category' => array( 'name' => 'category_count', 'op' => '=', 'val' => '0' ), |
115 | 112 | // no inbound links |
— | — | @@ -117,15 +114,20 @@ |
118 | 115 | 'non_autoconfirmed_users' => array( 'name' => 'user_autoconfirmed', 'op' => '=', 'val' => '0' ), |
119 | 116 | // blocked users |
120 | 117 | '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'] ) |
123 | 122 | ); |
124 | 123 | |
125 | 124 | $tags = ArticleMetadata::getValidTags(); |
126 | 125 | |
| 126 | + // only single tag search is allowed |
127 | 127 | foreach ( $searchableTags as $key => $val ) { |
128 | 128 | 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; |
130 | 132 | } |
131 | 133 | } |
132 | 134 | |
— | — | @@ -171,7 +173,9 @@ |
172 | 174 | 'blocked_users' => array( |
173 | 175 | ApiBase::PARAM_TYPE => 'boolean', |
174 | 176 | ), |
175 | | - |
| 177 | + 'username' => array( |
| 178 | + ApiBase::PARAM_TYPE => 'user', |
| 179 | + ), |
176 | 180 | ); |
177 | 181 | } |
178 | 182 | |
— | — | @@ -187,7 +191,8 @@ |
188 | 192 | 'no_category' => 'Whether to show only pages with no category', |
189 | 193 | 'no_inbound_links' => 'Whether to show only pages with no inbound links', |
190 | 194 | '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', |
192 | 197 | ); |
193 | 198 | } |
194 | 199 | |