Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -86,8 +86,9 @@ |
87 | 87 | # Scanning large datasets for rare categories sucks, and I already told |
88 | 88 | # how to have efficient subcategory access :-) ~~~~ (oh well, domas) |
89 | 89 | global $wgMiserMode; |
90 | | - if ( $wgMiserMode && isset($params['namespace']) ) { |
91 | | - $this->setWarning("The cmnamespace option is disabled on this site"); |
| 90 | + $miser_ns = array(); |
| 91 | + if ($wgMiserMode) { |
| 92 | + $miser_ns = $params['namespace']; |
92 | 93 | } else { |
93 | 94 | $this->addWhereFld('page_namespace', $params['namespace']); |
94 | 95 | } |
— | — | @@ -119,6 +120,13 @@ |
120 | 121 | break; |
121 | 122 | } |
122 | 123 | |
| 124 | + // Since domas won't tell anyone what he told long ago, apply |
| 125 | + // cmnamespace here. This means the query may return 0 actual |
| 126 | + // results, but on the other hand it could save returning 5000 |
| 127 | + // useless results to the client. ~~~~ |
| 128 | + if (count($miser_ns) && !in_array($row->page_namespace, $miser_ns)) |
| 129 | + continue; |
| 130 | + |
123 | 131 | if (is_null($resultPageSet)) { |
124 | 132 | $vals = array(); |
125 | 133 | if ($fld_ids) |
— | — | @@ -240,9 +248,11 @@ |
241 | 249 | } |
242 | 250 | |
243 | 251 | public function getParamDescription() { |
| 252 | + global $wgMiserMode; |
244 | 253 | $desc = array ( |
245 | 254 | 'title' => 'Which category to enumerate (required). Must include Category: prefix', |
246 | 255 | 'prop' => 'What pieces of information to include', |
| 256 | + 'namespace' => 'Only include pages in these namespaces', |
247 | 257 | 'sort' => 'Property to sort by', |
248 | 258 | 'dir' => 'In which direction to sort', |
249 | 259 | 'start' => 'Timestamp to start listing from. Can only be used with cmsort=timestamp', |
— | — | @@ -252,14 +262,13 @@ |
253 | 263 | 'continue' => 'For large categories, give the value retured from previous query', |
254 | 264 | 'limit' => 'The maximum number of pages to return.', |
255 | 265 | ); |
256 | | - global $wgMiserMode; |
257 | | - // We can't remove it from the param list entirely without removing it from the |
258 | | - // allowed params, but then we could only silently ignore it, which could cause |
259 | | - // problems for people unaware of the change |
260 | | - if ( $wgMiserMode ) |
261 | | - $desc['namespace'] = 'Disabled on this site for performance reasons'; |
262 | | - else |
263 | | - $desc['namespace'] = 'Only include pages in these namespaces'; |
| 266 | + if ($wgMiserMode) { |
| 267 | + $desc['namespace'] = array( |
| 268 | + $desc['namespace'], |
| 269 | + 'NOTE: Due to $wgMiserMode, using this may result in fewer than "limit" results', |
| 270 | + 'returned before continuing; in extreme cases, zero results may be returned.', |
| 271 | + ); |
| 272 | + } |
264 | 273 | return $desc; |
265 | 274 | } |
266 | 275 | |