API * better self-description for various modules
authorYuri Astrakhan <yurik@users.mediawiki.org>
Fri, 3 Nov 2006 06:53:47 +0000 (06:53 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Fri, 3 Nov 2006 06:53:47 +0000 (06:53 +0000)
* namespace type for parameters
* fixed bug with incorrect ordering in paging
* fixed bug with revisions and watchlist paging

17 files changed:
includes/api/ApiBase.php
includes/api/ApiFormatBase.php
includes/api/ApiFormatJson.php
includes/api/ApiFormatPhp.php
includes/api/ApiFormatWddx.php
includes/api/ApiFormatXml.php
includes/api/ApiFormatYaml.php
includes/api/ApiMain.php
includes/api/ApiQuery.php
includes/api/ApiQueryAllpages.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryContributions.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQueryWatchlist.php

index cee0018..569845f 100644 (file)
@@ -171,14 +171,20 @@ abstract class ApiBase {
                                if (is_array($desc))
                                        $desc = implode($paramPrefix, $desc);
 
-                               if (isset ($paramSettings[self :: PARAM_TYPE])) {
+                               @ $type = $paramSettings[self :: PARAM_TYPE];
+                               if (isset ($type)) {
                                        if (isset ($paramSettings[self :: PARAM_ISMULTI]))
-                                               $prompt = 'Multiple "|"-separated values: ';
+                                               $prompt = 'Values (separate with \'|\'): ';
                                        else
-                                               $prompt = 'Any one of these values: ';
-                                       $type = $paramSettings[self :: PARAM_TYPE];
-                                       if (is_array($type))
+                                               $prompt = 'One value: ';
+
+                                       if (is_array($type)) {
                                                $desc .= $paramPrefix . $prompt . implode(', ', $type);
+                                       }
+                                       elseif ($type == 'namespace') {
+                                               // Special handling because namespaces are type-limited, yet they are not given
+                                               $desc .= $paramPrefix . $prompt . implode(', ', ApiBase :: getValidNamespaces());
+                                       }
                                }
 
                                $default = is_array($paramSettings) ? (isset ($paramSettings[self :: PARAM_DFLT]) ? $paramSettings[self :: PARAM_DFLT] : null) : $paramSettings;
@@ -253,6 +259,20 @@ abstract class ApiBase {
                return $this->getParameterFromSettings($paramName, $paramSettings);
        }
 
+       public static function getValidNamespaces() {
+               static $mValidNamespaces = null;
+               if (is_null($mValidNamespaces)) {
+
+                       global $wgContLang;
+                       $mValidNamespaces = array ();
+                       foreach (array_keys($wgContLang->getNamespaces()) as $ns) {
+                               if ($ns >= 0)
+                                       $mValidNamespaces[] = $ns;
+                       }
+               }
+               return $mValidNamespaces;
+       }
+
        /**
         * Using the settings determine the value for the given parameter
         * @param $paramName String: parameter name
@@ -290,6 +310,9 @@ abstract class ApiBase {
                        $value = $this->getMain()->getRequest()->getCheck($paramName);
                } else {
                        $value = $this->getMain()->getRequest()->getVal($paramName, $default);
+
+                       if (isset ($value) && $type == 'namespace')
+                               $type = ApiBase :: getValidNamespaces();
                }
 
                if (isset ($value) && ($multi || is_array($type)))
index 0e31df1..d3a7a79 100644 (file)
@@ -165,6 +165,10 @@ for more information.
                return 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName();
        }
 
+       protected function getDescription() {
+               return $this->getIsHtml() ? ' (pretty-print in HTML)' : '';
+       }
+
        public static function getBaseVersion() {
                return __CLASS__ . ': $Id$';
        }
@@ -220,7 +224,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
                        wfHttpError(500, 'Internal Server Error', '');
                }
        }
-
+       
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }
index 7e72693..06dc99b 100644 (file)
@@ -32,20 +32,20 @@ if (!defined('MEDIAWIKI')) {
 class ApiFormatJson extends ApiFormatBase {
 
        private $mIsRaw;
-       
+
        public function __construct($main, $format) {
                parent :: __construct($main, $format);
-               $this->mIsRaw = ($format === 'raw' || $format === 'rawfm');
+               $this->mIsRaw = ($format === 'rawfm');
        }
 
        public function getMimeType() {
                return 'application/json';
        }
-       
+
        public function getNeedsRawData() {
                return $this->mIsRaw;
        }
-       
+
        public function execute() {
                if (!function_exists('json_encode') || $this->getIsHtml()) {
                        $json = new Services_JSON();
@@ -56,7 +56,10 @@ class ApiFormatJson extends ApiFormatBase {
        }
 
        protected function getDescription() {
-               return 'Output data in JSON format';
+               if ($this->mIsRaw)
+                       return 'Output data with the debuging elements in JSON format' . parent :: getDescription();
+               else
+                       return 'Output data in JSON format' . parent :: getDescription();
        }
 
        public function getVersion() {
index 0b0a820..f635f4c 100644 (file)
@@ -44,7 +44,7 @@ class ApiFormatPhp extends ApiFormatBase {
        }
 
        protected function getDescription() {
-               return 'Output data in serialized PHP format';
+               return 'Output data in serialized PHP format' . parent :: getDescription();
        }
 
        public function getVersion() {
index a075626..71f13d4 100644 (file)
@@ -79,7 +79,7 @@ class ApiFormatWddx extends ApiFormatBase {
        }
 
        protected function getDescription() {
-               return 'Output data in WDDX format';
+               return 'Output data in WDDX format' . parent :: getDescription();
        }
 
        public function getVersion() {
index 09621f6..5d4e776 100644 (file)
@@ -50,16 +50,8 @@ class ApiFormatXml extends ApiFormatBase {
        }
 
        public function execute() {
-               $xmlindent = null;
-               extract($this->extractRequestParams());
-
-               if ($xmlindent || $this->getIsHtml())
-                       $xmlindent = -2;
-               else
-                       $xmlindent = null;
-
                $this->printText('<?xml version="1.0" encoding="utf-8"?>');
-               $this->recXmlPrint($this->mRootElemName, $this->getResultData(), $xmlindent);
+               $this->recXmlPrint($this->mRootElemName, $this->getResultData(), $this->getIsHtml() ? -2 : null);
        }
 
        /**
@@ -143,19 +135,7 @@ class ApiFormatXml extends ApiFormatBase {
                }
        }
        protected function getDescription() {
-               return 'Output data in XML format';
-       }
-
-       protected function getAllowedParams() {
-               return array (
-                       'xmlindent' => false
-               );
-       }
-
-       protected function getParamDescription() {
-               return array (
-                       'xmlindent' => 'Enable XML indentation'
-               );
+               return 'Output data in XML format' . parent :: getDescription();
        }
 
        public function getVersion() {
index adb23cd..006e973 100644 (file)
@@ -44,7 +44,7 @@ class ApiFormatYaml extends ApiFormatBase {
        }
 
        protected function getDescription() {
-               return 'Output data in YAML format';
+               return 'Output data in YAML format' . parent :: getDescription();
        }
 
        public function getVersion() {
index 9fe2ccd..e93fc61 100644 (file)
@@ -64,7 +64,6 @@ class ApiMain extends ApiBase {
                'xmlfm' => 'ApiFormatXml',
                'yaml' => 'ApiFormatYaml',
                'yamlfm' => 'ApiFormatYaml',
-               'raw' => 'ApiFormatJson',
                'rawfm' => 'ApiFormatJson'
        );
 
index 7eef817..d58cc5c 100644 (file)
@@ -33,7 +33,6 @@ class ApiQuery extends ApiBase {
 
        private $mPropModuleNames, $mListModuleNames, $mMetaModuleNames;
        private $mPageSet;
-       private $mValidNamespaces;
 
        private $mQueryPropModules = array (
                'info' => 'ApiQueryInfo',
@@ -74,7 +73,6 @@ class ApiQuery extends ApiBase {
                $this->mPropModuleNames = array_keys($this->mQueryPropModules);
                $this->mListModuleNames = array_keys($this->mQueryListModules);
                $this->mMetaModuleNames = array_keys($this->mQueryMetaModules);
-               $this->mValidNamespaces = null;
 
                // Allow the entire list of modules at first,
                // but during module instantiation check if it can be used as a generator.
@@ -94,19 +92,6 @@ class ApiQuery extends ApiBase {
                return $this->mPageSet;
        }
 
-       public function getValidNamespaces() {
-               global $wgContLang;
-
-               if (is_null($this->mValidNamespaces)) {
-                       $this->mValidNamespaces = array ();
-                       foreach (array_keys($wgContLang->getNamespaces()) as $ns) {
-                               if ($ns >= 0)
-                                       $this->mValidNamespaces[] = $ns; // strval($ns);                
-                       }
-               }
-               return $this->mValidNamespaces;
-       }
-
        /**
         * Query execution happens in the following steps:
         * #1 Create a PageSet object with any pages requested by the user
index 71868a0..46abcda 100644 (file)
@@ -57,7 +57,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
                extract($this->extractRequestParams());
 
                $this->addTables('page');
-               if!$this->addWhereIf('page_is_redirect = 1', $filterredir === 'redirects'))
+               if (!$this->addWhereIf('page_is_redirect = 1', $filterredir === 'redirects'))
                        $this->addWhereIf('page_is_redirect = 0', $filterredir === 'nonredirects');
                $this->addWhereFld('page_namespace', $namespace);
                if (isset ($from))
@@ -66,18 +66,18 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
                        $this->addWhere("page_title LIKE '{$db->strencode(ApiQueryBase :: titleToKey($prefix))}%'");
 
                if (is_null($resultPageSet)) {
-                       $this->addFields( array (
+                       $this->addFields(array (
                                'page_id',
                                'page_namespace',
                                'page_title'
                        ));
                } else {
-                       $this->addFields( $resultPageSet->getPageTableFields());
+                       $this->addFields($resultPageSet->getPageTableFields());
                }
 
-               $this->addOption( 'USE INDEX', 'name_title');
-               $this->addOption( 'LIMIT', $limit +1);
-               $this->addOption( 'ORDER BY', 'page_namespace, page_title');
+               $this->addOption('USE INDEX', 'name_title');
+               $this->addOption('LIMIT', $limit +1);
+               $this->addOption('ORDER BY', 'page_namespace, page_title');
 
                wfProfileOut($this->getModuleProfileName() . '-parseParams');
 
@@ -96,7 +96,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
 
                        if (is_null($resultPageSet)) {
                                $vals = $this->addRowInfo('page', $row);
-                               if($vals)
+                               if ($vals)
                                        $data[intval($row->page_id)] = $vals;
                        } else {
                                $resultPageSet->processDbRow($row);
@@ -109,18 +109,17 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
                        $result->setIndexedTagName($data, 'p');
                        $result->addValue('query', $this->getModuleName(), $data);
                }
-               
+
                wfProfileOut($this->getModuleProfileName() . '-saveResults');
        }
 
        protected function getAllowedParams() {
-               $namespaces = $this->getQuery()->getValidNamespaces();
                return array (
                        'from' => null,
                        'prefix' => null,
                        'namespace' => array (
                                ApiBase :: PARAM_DFLT => 0,
-                               ApiBase :: PARAM_TYPE => $namespaces
+                               ApiBase :: PARAM_TYPE => 'namespace'
                        ),
                        'filterredir' => array (
                                ApiBase :: PARAM_DFLT => 'all',
index a5076b5..30228d4 100644 (file)
@@ -294,12 +294,11 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
 
        protected function getAllowedParams() {
 
-               $namespaces = $this->getQuery()->getValidNamespaces();
                return array (
                        'continue' => null,
                        'namespace' => array (
                                ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => $namespaces
+                               ApiBase :: PARAM_TYPE => 'namespace'
                        ),
                        'redirect' => false,
                        'limit' => array (
@@ -322,7 +321,16 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
        }
 
        protected function getDescription() {
-               return 'Find all pages that link to the given page';
+               switch ($this->getModuleName()) {
+                       case 'backlinks' :
+                               return 'Find all pages that link to the given page';
+                       case 'embeddedin' :
+                               return 'Find all pages that embed (transclude) the given title';
+                       case 'imagelinks' :
+                               return 'Find all pages that use the given image title.';
+                       default :
+                               ApiBase :: dieDebug(__METHOD__, 'Unknown module name');
+               }
        }
 
        protected function getExamples() {
index 03e51e4..4064075 100644 (file)
@@ -38,23 +38,23 @@ abstract class ApiQueryBase extends ApiBase {
                $this->mQueryModule = $query;
                $this->resetQueryParams();
        }
-       
+
        protected function resetQueryParams() {
                $this->tables = array ();
                $this->where = array ();
-               $this->fields = array();
+               $this->fields = array ();
                $this->options = array ();
        }
 
        protected function addTables($value) {
-               if(is_array($value))
+               if (is_array($value))
                        $this->tables = array_merge($this->tables, $value);
                else
                        $this->tables[] = $value;
        }
-       
-       protected function addFields($value) {  
-               if(is_array($value))
+
+       protected function addFields($value) {
+               if (is_array($value))
                        $this->fields = array_merge($this->fields, $value);
                else
                        $this->fields[] = $value;
@@ -67,14 +67,14 @@ abstract class ApiQueryBase extends ApiBase {
                }
                return false;
        }
-       
+
        protected function addWhere($value) {
-               if(is_array($value))
+               if (is_array($value))
                        $this->where = array_merge($this->where, $value);
                else
                        $this->where[] = $value;
        }
-       
+
        protected function addWhereIf($value, $condition) {
                if ($condition) {
                        $this->addWhere($value);
@@ -84,14 +84,14 @@ abstract class ApiQueryBase extends ApiBase {
        }
 
        protected function addWhereFld($field, $value) {
-               if(!is_null($value))
+               if (!is_null($value))
                        $this->where[$field] = $value;
        }
 
        protected function addWhereRange($field, $dir, $start, $end) {
                $isDirNewer = ($dir === 'newer');
-               $after = ($isDirNewer ? '<=' : '>=');
-               $before = ($isDirNewer ? '>=' : '<=');
+               $after = ($isDirNewer ? '>=' : '<=');
+               $before = ($isDirNewer ? '<=' : '>=');
                $db = & $this->getDB();
 
                if (!is_null($start))
@@ -99,40 +99,41 @@ abstract class ApiQueryBase extends ApiBase {
 
                if (!is_null($end))
                        $this->addWhere($field . $before . $db->addQuotes($end));
-                       
+
                $this->addOption('ORDER BY', $field . ($isDirNewer ? '' : ' DESC'));
        }
-       
+
        protected function addOption($name, $value = null) {
                if (is_null($value))
                        $this->options[] = $name;
                else
                        $this->options[$name] = $value;
        }
-       
+
        protected function select($method) {
-               
+
                // getDB has its own profileDBIn/Out calls
-               $db = & $this->getDB();         
-               
+               $db = & $this->getDB();
+
                $this->profileDBIn();
                $res = $db->select($this->tables, $this->fields, $this->where, $method, $this->options);
                $this->profileDBOut();
-               
+
                return $res;
        }
 
-
        protected function addRowInfo($prefix, $row) {
 
-               $vals = array();
-               
+               $vals = array ();
+
                // ID
-               @$tmp = $row->{$prefix . '_id'};
-               if(!is_null($tmp)) $vals[$prefix . 'id'] = intval($tmp);
+               @ $tmp = $row-> {
+                       $prefix . '_id' };
+               if (!is_null($tmp))
+                       $vals[$prefix . 'id'] = intval($tmp);
 
                // Title
-               $title = ApiQueryBase::addRowInfo_title($row, $prefix . '_namespace', $prefix . '_title');
+               $title = ApiQueryBase :: addRowInfo_title($row, $prefix . '_namespace', $prefix . '_title');
                if ($title) {
                        if (!$title->userCanRead())
                                return false;
@@ -140,44 +141,50 @@ abstract class ApiQueryBase extends ApiBase {
                        $vals['title'] = $title->getPrefixedText();
                }
 
-               switch($prefix) {
+               switch ($prefix) {
 
-                       case 'page':
+                       case 'page' :
                                // page_is_redirect
-                               @$tmp = $row->page_is_redirect;
-                               if($tmp) $vals['redirect'] = '';
+                               @ $tmp = $row->page_is_redirect;
+                               if ($tmp)
+                                       $vals['redirect'] = '';
 
                                break;
 
-                       case 'rc':
+                       case 'rc' :
                                // PageId
-                               @$tmp = $row->rc_cur_id;
-                               if(!is_null($tmp)) $vals['pageid'] = intval($tmp);
-       
-                               @$tmp = $row->rc_this_oldid;
-                               if(!is_null($tmp)) $vals['revid'] = intval($tmp);
-       
-                               @$tmp = $row->rc_last_oldid;
-                               if(!is_null($tmp)) $vals['old_revid'] = intval($tmp);
-       
-                               $title = ApiQueryBase::addRowInfo_title($row, 'rc_moved_to_ns', 'rc_moved_to_title');
+                               @ $tmp = $row->rc_cur_id;
+                               if (!is_null($tmp))
+                                       $vals['pageid'] = intval($tmp);
+
+                               @ $tmp = $row->rc_this_oldid;
+                               if (!is_null($tmp))
+                                       $vals['revid'] = intval($tmp);
+
+                               @ $tmp = $row->rc_last_oldid;
+                               if (!is_null($tmp))
+                                       $vals['old_revid'] = intval($tmp);
+
+                               $title = ApiQueryBase :: addRowInfo_title($row, 'rc_moved_to_ns', 'rc_moved_to_title');
                                if ($title) {
                                        if (!$title->userCanRead())
                                                return false;
                                        $vals['new_ns'] = $title->getNamespace();
                                        $vals['new_title'] = $title->getPrefixedText();
-                               }       
-       
-                               @$tmp = $row->rc_patrolled;
-                               if(!is_null($tmp)) $vals['patrolled'] = '';
+                               }
+
+                               @ $tmp = $row->rc_patrolled;
+                               if (!is_null($tmp))
+                                       $vals['patrolled'] = '';
 
                                break;
 
-                       case 'log':
+                       case 'log' :
                                // PageId
-                               @$tmp = $row->page_id;
-                               if(!is_null($tmp)) $vals['pageid'] = intval($tmp);
-       
+                               @ $tmp = $row->page_id;
+                               if (!is_null($tmp))
+                                       $vals['pageid'] = intval($tmp);
+
                                if ($row->log_params !== '') {
                                        $params = explode("\n", $row->log_params);
                                        if ($row->log_type == 'move' && isset ($params[0])) {
@@ -188,7 +195,7 @@ abstract class ApiQueryBase extends ApiBase {
                                                        $params = null;
                                                }
                                        }
-       
+
                                        if (!empty ($params)) {
                                                $this->getResult()->setIndexedTagName($params, 'param');
                                                $vals = array_merge($vals, $params);
@@ -197,66 +204,88 @@ abstract class ApiQueryBase extends ApiBase {
 
                                break;
 
-                       case 'rev':
+                       case 'rev' :
                                // PageID
-                               @$tmp = $row->rev_page;
-                               if (!is_null($tmp)) $vals['pageid'] = intval($tmp);
+                               @ $tmp = $row->rev_page;
+                               if (!is_null($tmp))
+                                       $vals['pageid'] = intval($tmp);
                }
 
                // Type
-               @$tmp = $row->{$prefix . '_type'};
-               if(!is_null($tmp)) $vals['type'] = $tmp;
+               @ $tmp = $row-> {
+                       $prefix . '_type' };
+               if (!is_null($tmp))
+                       $vals['type'] = $tmp;
 
                // Action
-               @$tmp = $row->{$prefix . '_action'};
-               if(!is_null($tmp)) $vals['action'] = $tmp;
-               
+               @ $tmp = $row-> {
+                       $prefix . '_action' };
+               if (!is_null($tmp))
+                       $vals['action'] = $tmp;
+
                // Old ID
-               @$tmp = $row->{$prefix . '_text_id'};
-               if(!is_null($tmp)) $vals['oldid'] = intval($tmp);
+               @ $tmp = $row-> {
+                       $prefix . '_text_id' };
+               if (!is_null($tmp))
+                       $vals['oldid'] = intval($tmp);
 
                // User Name / Anon IP
-               @$tmp = $row->{$prefix . '_user_text'};
-               if(is_null($tmp)) @$tmp = $row->user_name;
-               if(!is_null($tmp)) {
+               @ $tmp = $row-> {
+                       $prefix . '_user_text' };
+               if (is_null($tmp))
+                       @ $tmp = $row->user_name;
+               if (!is_null($tmp)) {
                        $vals['user'] = $tmp;
-                       @$tmp = !$row->{$prefix . '_user'};
-                       if(!is_null($tmp) && $tmp)
+                       @ $tmp = !$row-> {
+                               $prefix . '_user' };
+                       if (!is_null($tmp) && $tmp)
                                $vals['anon'] = '';
                }
-               
+
                // Bot Edit
-               @$tmp = $row->{$prefix . '_bot'};
-               if(!is_null($tmp) && $tmp) $vals['bot'] = '';
-               
+               @ $tmp = $row-> {
+                       $prefix . '_bot' };
+               if (!is_null($tmp) && $tmp)
+                       $vals['bot'] = '';
+
                // New Edit
-               @$tmp = $row->{$prefix . '_new'};
-               if(is_null($tmp)) @$tmp = $row->{$prefix . '_is_new'};
-               if(!is_null($tmp) && $tmp) $vals['new'] = '';
-               
+               @ $tmp = $row-> {
+                       $prefix . '_new' };
+               if (is_null($tmp))
+                       @ $tmp = $row-> {
+                       $prefix . '_is_new' };
+               if (!is_null($tmp) && $tmp)
+                       $vals['new'] = '';
+
                // Minor Edit
-               @$tmp = $row->{$prefix . '_minor_edit'};
-               if(is_null($tmp)) @$tmp = $row->{$prefix . '_minor'};
-               if(!is_null($tmp) && $tmp) $vals['minor'] = '';
-               
+               @ $tmp = $row-> {
+                       $prefix . '_minor_edit' };
+               if (is_null($tmp))
+                       @ $tmp = $row-> {
+                       $prefix . '_minor' };
+               if (!is_null($tmp) && $tmp)
+                       $vals['minor'] = '';
+
                // Timestamp
-               @$tmp = $row->{$prefix . '_timestamp'};
-               if(!is_null($tmp))
+               @ $tmp = $row-> {
+                       $prefix . '_timestamp' };
+               if (!is_null($tmp))
                        $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $tmp);
 
                // Comment
-               @$tmp = $row->{$prefix . '_comment'};
-               if(!empty($tmp))        // optimize bandwidth
+               @ $tmp = $row-> {
+                       $prefix . '_comment' };
+               if (!empty ($tmp)) // optimize bandwidth
                        $vals['comment'] = $tmp;
-                       
+
                return $vals;
-       }  
+       }
 
        private static function addRowInfo_title($row, $nsfld, $titlefld) {
-               @$ns = $row->$nsfld;
-               if(!is_null($ns)) {
-                       @$title = $row->$titlefld;
-                       if(!empty($title))
+               @ $ns = $row-> $nsfld;
+               if (!is_null($ns)) {
+                       @ $title = $row-> $titlefld;
+                       if (!empty ($title))
                                return Title :: makeTitle($ns, $title);
                }
                return false;
index 60b140e..5bb880a 100644 (file)
@@ -46,6 +46,8 @@ class ApiQueryContributions extends ApiQueryBase {
                //Get a database instance
                $db = & $this->getDB();
 
+               if (is_null($user))
+                       $this->dieUsage("User parameter may not be empty", 'param_user');
                $userid = $db->selectField('user', 'user_id', array (
                        'user_name' => $user
                ));
@@ -159,7 +161,7 @@ class ApiQueryContributions extends ApiQueryBase {
 
        protected function getExamples() {
                return array (
-                       'api.php?action=query&list=usercontribs&ucuser=Werdna'
+                       'api.php?action=query&list=usercontribs&ucuser=YurikBot'
                );
        }
 
index 1f92fd6..4c894bc 100644 (file)
@@ -104,13 +104,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
 
        protected function getAllowedParams() {
                return array (
-                       'limit' => array (
-                               ApiBase :: PARAM_DFLT => 10,
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX1 => ApiBase :: LIMIT_BIG1,
-                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
-                       ),
                        'type' => array (
                                ApiBase :: PARAM_ISMULTI => true,
                                ApiBase :: PARAM_TYPE => array (
@@ -140,19 +133,26 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                )
                        ),
                        'user' => null,
-                       'title' => null
+                       'title' => null,
+                       'limit' => array (
+                               ApiBase :: PARAM_DFLT => 10,
+                               ApiBase :: PARAM_TYPE => 'limit',
+                               ApiBase :: PARAM_MIN => 1,
+                               ApiBase :: PARAM_MAX1 => ApiBase :: LIMIT_BIG1,
+                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+                       )
                );
        }
 
        protected function getParamDescription() {
                return array (
-                       'limit' => '',
-                       'type' => '',
-                       'start' => '',
-                       'end' => '',
-                       'dir' => '',
-                       'user' => '',
-                       'title' => ''
+                       'type' => 'Filter log entries to only this type(s)',
+                       'start' => 'The timestamp to start enumerating from.',
+                       'end' => 'The timestamp to end enumerating.',
+                       'dir' => 'In which direction to enumerate.',
+                       'user' => 'Filter entries to those made by the given user.',
+                       'title' => 'Filter entries to those related to a page.',
+                       'limit' => 'How many total event entries to return.'
                );
        }
 
index e086b50..2bf20d1 100644 (file)
@@ -105,8 +105,13 @@ class ApiQueryRecentChanges extends ApiQueryBase {
        }
 
        protected function getAllowedParams() {
-               $namespaces = $this->getQuery()->getValidNamespaces();
                return array (
+                       'start' => array (
+                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       ),
+                       'end' => array (
+                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       ),
                        'dir' => array (
                                ApiBase :: PARAM_DFLT => 'older',
                                ApiBase :: PARAM_TYPE => array (
@@ -114,15 +119,9 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                                        'older'
                                )
                        ),
-                       'start' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
-                       ),
-                       'end' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
-                       ),
                        'namespace' => array (
-                               ApiBase :: PARAM_DFLT => 0,
-                               ApiBase :: PARAM_TYPE => $namespaces
+                               ApiBase :: PARAM_ISMULTI => true,
+                               ApiBase :: PARAM_TYPE => 'namespace'
                        ),
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
@@ -155,6 +154,10 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                return array (
                        'start' => 'The timestamp to start enumerating from.',
                        'end' => 'The timestamp to end enumerating.',
+                       'dir' => 'In which direction to enumerate.',
+                       'namespace' => 'Filter log entries to only this namespace(s)',
+                       'prop' => 'Include additional pieces of information',
+                       'hide' => 'Hide certain changes (minor edits, bots, anonymous, logged-in-users)',
                        'limit' => 'How many total pages to return.'
                );
        }
index 6efb638..a9dd340 100644 (file)
@@ -108,9 +108,9 @@ class ApiQueryRevisions extends ApiQueryBase {
                        // The order needs to be the same as start parameter to avoid SQL filesort.
 
                        if (is_null($startid))
-                               $this->addWhereRange('rev_id', $dir, $startid, $endid);
-                       else
                                $this->addWhereRange('rev_timestamp', $dir, $start, $end);
+                       else
+                               $this->addWhereRange('rev_id', $dir, $startid, $endid);
 
                        // must manually initialize unset limit
                        if (is_null($limit))
index dcd0c45..595cb75 100644 (file)
@@ -129,7 +129,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                while ($row = $db->fetchObject($res)) {
                        if (++ $count > $limit) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
-                               $this->setContinueEnumParameter('from', $row->rc_timestamp);
+                               $this->setContinueEnumParameter('start', $row->rc_timestamp);
                                break;
                        }
 
@@ -164,7 +164,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
        }
 
        protected function getAllowedParams() {
-               $namespaces = $this->getQuery()->getValidNamespaces();
                return array (
                        'allrev' => false,
                        'start' => array (
@@ -175,7 +174,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        ),
                        'namespace' => array (
                                ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => $namespaces
+                               ApiBase :: PARAM_TYPE => 'namespace'
                        ),
                        'dir' => array (
                                ApiBase :: PARAM_DFLT => 'older',