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
This commit is contained in:
Alex Z 2009-07-10 23:46:13 +00:00
parent 6eca5b4e6a
commit 20b9b18781

View file

@ -86,9 +86,11 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
# Scanning large datasets for rare categories sucks, and I already told # Scanning large datasets for rare categories sucks, and I already told
# how to have efficient subcategory access :-) ~~~~ (oh well, domas) # how to have efficient subcategory access :-) ~~~~ (oh well, domas)
global $wgMiserMode; global $wgMiserMode;
if (!$wgMiserMode) { if ( $wgMiserMode && isset($params['namespace']) ) {
$this->addWhereFld('page_namespace', $params['namespace']); $this->dieUsage("The cmnamespace option is disabled on this site", 'namespacedisabled');
} }
$this->addWhereFld('page_namespace', $params['namespace']);
if($params['sort'] == 'timestamp') if($params['sort'] == 'timestamp')
$this->addWhereRange('cl_timestamp', ($params['dir'] == 'asc' ? 'newer' : 'older'), $params['start'], $params['end']); $this->addWhereRange('cl_timestamp', ($params['dir'] == 'asc' ? 'newer' : 'older'), $params['start'], $params['end']);
else else
@ -238,10 +240,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
} }
public function getParamDescription() { public function getParamDescription() {
return array ( $desc = array (
'title' => 'Which category to enumerate (required). Must include Category: prefix', 'title' => 'Which category to enumerate (required). Must include Category: prefix',
'prop' => 'What pieces of information to include', 'prop' => 'What pieces of information to include',
'namespace' => 'Only include pages in these namespaces',
'sort' => 'Property to sort by', 'sort' => 'Property to sort by',
'dir' => 'In which direction to sort', 'dir' => 'In which direction to sort',
'start' => 'Timestamp to start listing from. Can only be used with cmsort=timestamp', 'start' => 'Timestamp to start listing from. Can only be used with cmsort=timestamp',
@ -251,6 +252,15 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
'continue' => 'For large categories, give the value retured from previous query', 'continue' => 'For large categories, give the value retured from previous query',
'limit' => 'The maximum number of pages to return.', 'limit' => 'The maximum number of pages to return.',
); );
global $wgMiserMode;
// We can't remove it from the param list entirely without removing it from the
// allowed params, but then we could only silently ignore it, which could cause
// problems for people unaware of the change
if ( $wgMiserMode )
$desc['namespace'] = 'Disabled on this site for performance reasons';
else
$desc['namespace'] = 'Only include pages in these namespaces';
return $desc;
} }
public function getDescription() { public function getDescription() {
@ -269,4 +279,4 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
public function getVersion() { public function getVersion() {
return __CLASS__ . ': $Id$'; return __CLASS__ . ': $Id$';
} }
} }