r53087 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53086‎ | r53087 | r53088 >
Date:23:46, 10 July 2009
Author:mrzman
Status:resolved (Comments)
Tags:
Comment:
Followup to r53052 - Die if someone tries to use the namespace filter, rather than silently igoring it.
Add a note if its disabled in the param description
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -86,9 +86,11 @@
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) {
91 - $this->addWhereFld('page_namespace', $params['namespace']);
 90+ if ( $wgMiserMode && isset($params['namespace']) ) {
 91+ $this->dieUsage("The cmnamespace option is disabled on this site", 'namespacedisabled');
9292 }
 93+ $this->addWhereFld('page_namespace', $params['namespace']);
 94+
9395 if($params['sort'] == 'timestamp')
9496 $this->addWhereRange('cl_timestamp', ($params['dir'] == 'asc' ? 'newer' : 'older'), $params['start'], $params['end']);
9597 else
@@ -238,10 +240,9 @@
239241 }
240242
241243 public function getParamDescription() {
242 - return array (
 244+ $desc = array (
243245 'title' => 'Which category to enumerate (required). Must include Category: prefix',
244246 'prop' => 'What pieces of information to include',
245 - 'namespace' => 'Only include pages in these namespaces',
246247 'sort' => 'Property to sort by',
247248 'dir' => 'In which direction to sort',
248249 'start' => 'Timestamp to start listing from. Can only be used with cmsort=timestamp',
@@ -251,6 +252,15 @@
252253 'continue' => 'For large categories, give the value retured from previous query',
253254 'limit' => 'The maximum number of pages to return.',
254255 );
 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';
 264+ return $desc;
255265 }
256266
257267 public function getDescription() {
@@ -269,4 +279,4 @@
270280 public function getVersion() {
271281 return __CLASS__ . ': $Id$';
272282 }
273 -}
\ No newline at end of file
 283+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r53168Followup to r53087 / r53052 - Change dieUsage to setWarning per CodeReviewmrzman14:54, 13 July 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53052don't allow querying specific namespace if misermode is enabledmidom13:55, 10 July 2009

Comments

#Comment by Catrope (talk | contribs)   18:16, 11 July 2009

I think it'd be better to throw a warning instead of an error

#Comment by Mr.Z-man (talk | contribs)   20:29, 11 July 2009

I considered that, but was worried a warning may not really have the intended effect - to act as a failsafe (return nothing rather than returning incorrect data from a previously-working query)

#Comment by 😂 (talk | contribs)   13:00, 13 July 2009

Agree with Roan on this one: we shouldn't die entirely because of this, a warning is much better.

Status & tagging log