r53304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53303‎ | r53304 | r53305 >
Date:10:07, 15 July 2009
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 19640) API: Unbreak cmnamespace in miser mode by filtering on the PHP side. This is a dirty, temporary hack that'll have to do until we can do this properly on the database side.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -86,8 +86,9 @@
8787 # Scanning large datasets for rare categories sucks, and I already told
8888 # how to have efficient subcategory access :-) ~~~~ (oh well, domas)
8989 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'];
9293 } else {
9394 $this->addWhereFld('page_namespace', $params['namespace']);
9495 }
@@ -119,6 +120,13 @@
120121 break;
121122 }
122123
 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+
123131 if (is_null($resultPageSet)) {
124132 $vals = array();
125133 if ($fld_ids)
@@ -240,9 +248,11 @@
241249 }
242250
243251 public function getParamDescription() {
 252+ global $wgMiserMode;
244253 $desc = array (
245254 'title' => 'Which category to enumerate (required). Must include Category: prefix',
246255 'prop' => 'What pieces of information to include',
 256+ 'namespace' => 'Only include pages in these namespaces',
247257 'sort' => 'Property to sort by',
248258 'dir' => 'In which direction to sort',
249259 'start' => 'Timestamp to start listing from. Can only be used with cmsort=timestamp',
@@ -252,14 +262,13 @@
253263 'continue' => 'For large categories, give the value retured from previous query',
254264 'limit' => 'The maximum number of pages to return.',
255265 );
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+ }
264273 return $desc;
265274 }
266275

Comments

#Comment by Catrope (talk | contribs)   10:08, 15 July 2009

Patch by Brad Jorsch

#Comment by Simetrical (talk | contribs)   22:15, 15 July 2009

Um, "~~~~" in code comments?

#Comment by Anomie (talk | contribs)   02:42, 19 July 2009

Any chance of getting this synced any time soon, so we can be done dealing with the breakage caused by r53052?

#Comment by Ost316 (talk | contribs)   19:33, 25 August 2009

Is there any progress on this?

#Comment by Simetrical (talk | contribs)   00:30, 26 August 2009

It's been marked ok and will presumably go live at the next general sync. Brion is doing bunches of code review now, so that might be in the next few days if we're lucky. You can go to #wikimedia-tech on freenode and pester people there if you want to try getting it synced faster, but they tend to be reluctant to sync nontrivial things that aren't absolutely critical (security/site stability/major loss of functionality for many users ― and no, this doesn't count as the latter).

Status & tagging log