Followup to r53052 - Die if someone tries to use the namespace filter, rather than...
authorAlex Z <mrzman@users.mediawiki.org>
Fri, 10 Jul 2009 23:46:13 +0000 (23:46 +0000)
committerAlex Z <mrzman@users.mediawiki.org>
Fri, 10 Jul 2009 23:46:13 +0000 (23:46 +0000)
Add a note if its disabled in the param description

includes/api/ApiQueryCategoryMembers.php

index 4363776..5fc9957 100644 (file)
@@ -86,9 +86,11 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                # Scanning large datasets for rare categories sucks, and I already told 
                # how to have efficient subcategory access :-) ~~~~ (oh well, domas)
                global $wgMiserMode;
-               if (!$wgMiserMode) { 
-                       $this->addWhereFld('page_namespace', $params['namespace']);
+               if ( $wgMiserMode && isset($params['namespace']) ) { 
+                       $this->dieUsage("The cmnamespace option is disabled on this site", 'namespacedisabled');
                }
+               $this->addWhereFld('page_namespace', $params['namespace']);
+
                if($params['sort'] == 'timestamp')
                        $this->addWhereRange('cl_timestamp', ($params['dir'] == 'asc' ? 'newer' : 'older'), $params['start'], $params['end']);
                else
@@ -238,10 +240,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
        }
 
        public function getParamDescription() {
-               return array (
+               $desc = array (
                        'title' => 'Which category to enumerate (required). Must include Category: prefix',
                        'prop' => 'What pieces of information to include',
-                       'namespace' => 'Only include pages in these namespaces',
                        'sort' => 'Property to sort by',
                        'dir' => 'In which direction to sort',
                        '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',
                        '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() {
@@ -269,4 +279,4 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }
-}
\ No newline at end of file
+}