Merge "SpecialChangeEmail: Remove cancel button"
[lhc/web/wiklou.git] / includes / api / ApiQuery.php
index 94727cb..8407fad 100644 (file)
@@ -108,6 +108,7 @@ class ApiQuery extends ApiBase {
                'siteinfo' => 'ApiQuerySiteinfo',
                'userinfo' => 'ApiQueryUserInfo',
                'filerepoinfo' => 'ApiQueryFileRepoInfo',
+               'tokens' => 'ApiQueryTokens',
        );
 
        /**
@@ -348,29 +349,29 @@ class ApiQuery extends ApiBase {
                $pageSet = $this->getPageSet();
                $result = $this->getResult();
 
-               // We don't check for a full result set here because we can't be adding
-               // more than 380K. The maximum revision size is in the megabyte range,
-               // and the maximum result size must be even higher than that.
+               // We can't really handle max-result-size failure here, but we need to
+               // check anyway in case someone set the limit stupidly low.
+               $fit = true;
 
                $values = $pageSet->getNormalizedTitlesAsResult( $result );
                if ( $values ) {
-                       $result->addValue( 'query', 'normalized', $values );
+                       $fit = $fit && $result->addValue( 'query', 'normalized', $values );
                }
                $values = $pageSet->getConvertedTitlesAsResult( $result );
                if ( $values ) {
-                       $result->addValue( 'query', 'converted', $values );
+                       $fit = $fit && $result->addValue( 'query', 'converted', $values );
                }
                $values = $pageSet->getInterwikiTitlesAsResult( $result, $this->mParams['iwurl'] );
                if ( $values ) {
-                       $result->addValue( 'query', 'interwiki', $values );
+                       $fit = $fit && $result->addValue( 'query', 'interwiki', $values );
                }
                $values = $pageSet->getRedirectTitlesAsResult( $result );
                if ( $values ) {
-                       $result->addValue( 'query', 'redirects', $values );
+                       $fit = $fit && $result->addValue( 'query', 'redirects', $values );
                }
                $values = $pageSet->getMissingRevisionIDsAsResult( $result );
                if ( $values ) {
-                       $result->addValue( 'query', 'badrevids', $values );
+                       $fit = $fit && $result->addValue( 'query', 'badrevids', $values );
                }
 
                // Page elements
@@ -426,12 +427,21 @@ class ApiQuery extends ApiBase {
                                // json treats all map keys as strings - converting to match
                                $pageIDs = array_map( 'strval', $pageIDs );
                                $result->setIndexedTagName( $pageIDs, 'id' );
-                               $result->addValue( 'query', 'pageids', $pageIDs );
+                               $fit = $fit && $result->addValue( 'query', 'pageids', $pageIDs );
                        }
 
                        $result->setIndexedTagName( $pages, 'page' );
-                       $result->addValue( 'query', 'pages', $pages );
+                       $fit = $fit && $result->addValue( 'query', 'pages', $pages );
                }
+
+               if ( !$fit ) {
+                       $this->dieUsage(
+                               'The value of $wgAPIMaxResultSize on this wiki is ' .
+                                       'too small to hold basic result information',
+                               'badconfig'
+                       );
+               }
+
                if ( $this->mParams['export'] ) {
                        $this->doExport( $pageSet, $result );
                }
@@ -501,21 +511,22 @@ class ApiQuery extends ApiBase {
                $result = array(
                        'prop' => array(
                                ApiBase::PARAM_ISMULTI => true,
-                               ApiBase::PARAM_TYPE => $this->mModuleMgr->getNames( 'prop' )
+                               ApiBase::PARAM_TYPE => 'submodule',
                        ),
                        'list' => array(
                                ApiBase::PARAM_ISMULTI => true,
-                               ApiBase::PARAM_TYPE => $this->mModuleMgr->getNames( 'list' )
+                               ApiBase::PARAM_TYPE => 'submodule',
                        ),
                        'meta' => array(
                                ApiBase::PARAM_ISMULTI => true,
-                               ApiBase::PARAM_TYPE => $this->mModuleMgr->getNames( 'meta' )
+                               ApiBase::PARAM_TYPE => 'submodule',
                        ),
                        'indexpageids' => false,
                        'export' => false,
                        'exportnowrap' => false,
                        'iwurl' => false,
                        'continue' => null,
+                       'rawcontinue' => false,
                );
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );
@@ -598,6 +609,8 @@ class ApiQuery extends ApiBase {
                                'This parameter is recommended for all new development, and ' .
                                        'will be made default in the next API version.'
                        ),
+                       'rawcontinue' => 'Currently ignored. In the future, \'continue=\' will become the ' .
+                               'default and this will be needed to receive the raw query-continue data.',
                );
        }
 
@@ -611,13 +624,6 @@ class ApiQuery extends ApiBase {
                );
        }
 
-       public function getPossibleErrors() {
-               return array_merge(
-                       parent::getPossibleErrors(),
-                       $this->getPageSet()->getFinalPossibleErrors()
-               );
-       }
-
        public function getExamples() {
                return array(
                        'api.php?action=query&prop=revisions&meta=siteinfo&' .