Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | $fld_title = isset( $prop['title'] ); |
80 | 80 | $fld_sortkey = isset( $prop['sortkey'] ); |
81 | 81 | $fld_timestamp = isset( $prop['timestamp'] ); |
| 82 | + $fld_type = isset( $prop['type'] ); |
82 | 83 | |
83 | 84 | if ( is_null( $resultPageSet ) ) { |
84 | 85 | $this->addFields( array( 'cl_from', 'cl_sortkey', 'page_namespace', 'page_title' ) ); |
— | — | @@ -88,8 +89,10 @@ |
89 | 90 | } |
90 | 91 | |
91 | 92 | $this->addFieldsIf( 'cl_timestamp', $fld_timestamp || $params['sort'] == 'timestamp' ); |
| 93 | + $this->addFieldsIf( 'cl_type', $fld_type ); |
92 | 94 | $this->addTables( array( 'page', 'categorylinks' ) ); // must be in this order for 'USE INDEX' |
93 | | - // Not needed after bug 10280 is applied to servers |
| 95 | + |
| 96 | + // Not needed after bug 10280 is applied to servers |
94 | 97 | if ( $params['sort'] == 'timestamp' ) { |
95 | 98 | $this->addOption( 'USE INDEX', 'cl_timestamp' ); |
96 | 99 | } else { |
— | — | @@ -99,6 +102,9 @@ |
100 | 103 | $this->addWhere( 'cl_from=page_id' ); |
101 | 104 | $this->setContinuation( $params['continue'], $params['dir'] ); |
102 | 105 | $this->addWhereFld( 'cl_to', $categoryTitle->getDBkey() ); |
| 106 | + |
| 107 | + $this->addWhereFld( 'cl_type', $params['type'] ); |
| 108 | + |
103 | 109 | // Scanning large datasets for rare categories sucks, and I already told |
104 | 110 | // how to have efficient subcategory access :-) ~~~~ (oh well, domas) |
105 | 111 | global $wgMiserMode; |
— | — | @@ -108,11 +114,21 @@ |
109 | 115 | } else { |
110 | 116 | $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
111 | 117 | } |
| 118 | + |
| 119 | + $dir = $params['dir'] == 'asc' ? 'newer' : 'older'; |
| 120 | + |
112 | 121 | if ( $params['sort'] == 'timestamp' ) { |
113 | | - $this->addWhereRange( 'cl_timestamp', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['start'], $params['end'] ); |
| 122 | + $this->addWhereRange( 'cl_timestamp', |
| 123 | + $dir, |
| 124 | + $params['start'], |
| 125 | + $params['end'] ); |
114 | 126 | } else { |
115 | | - $this->addWhereRange( 'cl_sortkey', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['startsortkey'], $params['endsortkey'] ); |
116 | | - $this->addWhereRange( 'cl_from', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), null, null ); |
| 127 | + $this->addWhereRange( 'cl_sortkey', |
| 128 | + $dir, |
| 129 | + $params['startsortkey'], |
| 130 | + $params['endsortkey'] ); |
| 131 | + |
| 132 | + $this->addWhereRange( 'cl_from', $dir, null, null ); |
117 | 133 | } |
118 | 134 | |
119 | 135 | $limit = $params['limit']; |
— | — | @@ -153,6 +169,9 @@ |
154 | 170 | if ( $fld_sortkey ) { |
155 | 171 | $vals['sortkey'] = $row->cl_sortkey; |
156 | 172 | } |
| 173 | + if ( $fld_type ) { |
| 174 | + $vals['type'] = $row->cl_type; |
| 175 | + } |
157 | 176 | if ( $fld_timestamp ) { |
158 | 177 | $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp ); |
159 | 178 | } |
— | — | @@ -231,6 +250,7 @@ |
232 | 251 | 'ids', |
233 | 252 | 'title', |
234 | 253 | 'sortkey', |
| 254 | + 'type', |
235 | 255 | 'timestamp', |
236 | 256 | ) |
237 | 257 | ), |
— | — | @@ -238,6 +258,15 @@ |
239 | 259 | ApiBase::PARAM_ISMULTI => true, |
240 | 260 | ApiBase::PARAM_TYPE => 'namespace', |
241 | 261 | ), |
| 262 | + 'type' => array( |
| 263 | + ApiBase::PARAM_ISMULTI => true, |
| 264 | + ApiBase::PARAM_DFLT => 'page|subcat|file', |
| 265 | + ApiBase::PARAM_TYPE => array( |
| 266 | + 'page', |
| 267 | + 'subcat', |
| 268 | + 'file' |
| 269 | + ) |
| 270 | + ), |
242 | 271 | 'continue' => null, |
243 | 272 | 'limit' => array( |
244 | 273 | ApiBase::PARAM_TYPE => 'limit', |
— | — | @@ -285,6 +314,7 @@ |
286 | 315 | ' timestamp - Adds the timestamp of when the page was included', |
287 | 316 | ), |
288 | 317 | 'namespace' => 'Only include pages in these namespaces', |
| 318 | + 'type' => 'What type of category members to include', |
289 | 319 | 'sort' => 'Property to sort by', |
290 | 320 | 'dir' => 'In which direction to sort', |
291 | 321 | 'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp", |