Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata
[lhc/web/wiklou.git] / includes / api / ApiQuery.php
index edeb9c8..866b71c 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( 'ApiBase.php' );
-}
-
 /**
  * This is the main query class. It behaves similar to ApiMain: based on the
  * parameters given, it will create a list of titles to work on (an ApiPageSet
@@ -69,8 +64,8 @@ class ApiQuery extends ApiBase {
        );
 
        private $mQueryListModules = array(
-               'allimages' => 'ApiQueryAllimages',
-               'allpages' => 'ApiQueryAllpages',
+               'allimages' => 'ApiQueryAllImages',
+               'allpages' => 'ApiQueryAllPages',
                'alllinks' => 'ApiQueryAllLinks',
                'allcategories' => 'ApiQueryAllCategories',
                'allusers' => 'ApiQueryAllUsers',
@@ -100,12 +95,14 @@ class ApiQuery extends ApiBase {
        private $mQueryMetaModules = array(
                'siteinfo' => 'ApiQuerySiteinfo',
                'userinfo' => 'ApiQueryUserInfo',
-               'allmessages' => 'ApiQueryAllmessages',
+               'allmessages' => 'ApiQueryAllMessages',
        );
 
        private $mSlaveDB = null;
        private $mNamedDB = array();
 
+       protected $mAllowedGenerators = array();
+
        public function __construct( $main, $action ) {
                parent::__construct( $main, $action );
 
@@ -119,9 +116,8 @@ class ApiQuery extends ApiBase {
                $this->mListModuleNames = array_keys( $this->mQueryListModules );
                $this->mMetaModuleNames = array_keys( $this->mQueryMetaModules );
 
-               // Allow the entire list of modules at first,
-               // but during module instantiation check if it can be used as a generator.
-               $this->mAllowedGenerators = array_merge( $this->mListModuleNames, $this->mPropModuleNames );
+               $this->makeHelpMsgHelper( $this->mQueryPropModules, 'prop' );
+               $this->makeHelpMsgHelper( $this->mQueryListModules, 'list' );
        }
 
        /**
@@ -139,7 +135,7 @@ class ApiQuery extends ApiBase {
 
        /**
         * Gets a default slave database connection object
-        * @return Database
+        * @return DatabaseBase
         */
        public function getDB() {
                if ( !isset( $this->mSlaveDB ) ) {
@@ -158,7 +154,7 @@ class ApiQuery extends ApiBase {
         * @param $name string Name to assign to the database connection
         * @param $db int One of the DB_* constants
         * @param $groups array Query groups
-        * @return Database
+        * @return DatabaseBase
         */
        public function getNamedDB( $name, $db, $groups ) {
                if ( !array_key_exists( $name, $this->mNamedDB ) ) {
@@ -443,7 +439,7 @@ class ApiQuery extends ApiBase {
                        $vals = array();
                        ApiQueryBase::addTitleInfo( $vals, $title );
                        $vals['special'] = '';
-                       if ( $title->getNamespace() == NS_SPECIAL &&
+                       if ( $title->isSpecialPage() &&
                                        !SpecialPageFactory::exists( $title->getDbKey() ) ) {
                                $vals['missing'] = '';
                        } elseif ( $title->getNamespace() == NS_MEDIA &&
@@ -487,7 +483,7 @@ class ApiQuery extends ApiBase {
                $titles = $pageSet->getGoodTitles();
                if ( count( $titles ) ) {
                        foreach ( $titles as $title ) {
-                               if ( $title->userCanRead() ) {
+                               if ( $title->userCan( 'read' ) ) {
                                        $exportTitles[] = $title;
                                }
                        }
@@ -636,6 +632,9 @@ class ApiQuery extends ApiBase {
                $moduleDescriptions = array();
 
                foreach ( $moduleList as $moduleName => $moduleClass ) {
+                       /**
+                        * @var $module ApiQueryBase
+                        */
                        $module = new $moduleClass( $this, $moduleName, null );
 
                        $msg = ApiMain::makeHelpMsgHeader( $module, $paramName );
@@ -675,7 +674,7 @@ class ApiQuery extends ApiBase {
                                        'NOTE: generator parameter names must be prefixed with a \'g\', see examples' ),
                        'redirects' => 'Automatically resolve redirects',
                        'converttitles' => array( "Convert titles to other variants if necessary. Only works if the wiki's content language supports variant conversion.",
-                                       'Languages that support variant conversion include kk, ku, gan, tg, sr, zh' ),
+                                       'Languages that support variant conversion include gan, iu, kk, ku, shi, sr, tg, zh' ),
                        'indexpageids' => 'Include an additional pageids section listing all returned page IDs',
                        'export' => 'Export the current revisions of all given or generated pages',
                        'exportnowrap' => 'Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export',
@@ -706,9 +705,9 @@ class ApiQuery extends ApiBase {
 
        public function getHelpUrls() {
                return array(
-                       'http://www.mediawiki.org/wiki/API:Meta',
-                       'http://www.mediawiki.org/wiki/API:Properties',
-                       'http://www.mediawiki.org/wiki/API:Lists',
+                       'https://www.mediawiki.org/wiki/API:Meta',
+                       'https://www.mediawiki.org/wiki/API:Properties',
+                       'https://www.mediawiki.org/wiki/API:Lists',
                );
        }