Merge "Title: Fix subpage move error reporting"
[lhc/web/wiklou.git] / includes / api / ApiQuery.php
index e8aa655..8196cfa 100644 (file)
@@ -168,7 +168,7 @@ class ApiQuery extends ApiBase {
         * @param string $name Name to assign to the database connection
         * @param int $db One of the DB_* constants
         * @param array $groups Query groups
-        * @return DatabaseBase
+        * @return Database
         */
        public function getNamedDB( $name, $db, $groups ) {
                if ( !array_key_exists( $name, $this->mNamedDB ) ) {
@@ -310,7 +310,7 @@ class ApiQuery extends ApiBase {
                                        ApiBase::dieDebug( __METHOD__, 'Error instantiating module' );
                                }
                                if ( !$wasPosted && $instance->mustBePosted() ) {
-                                       $this->dieUsageMsgOrDebug( [ 'mustbeposted', $moduleName ] );
+                                       $this->dieWithErrorOrDebug( [ 'apierror-mustbeposted', $moduleName ] );
                                }
                                // Ignore duplicates. TODO 2.0: die()?
                                if ( !array_key_exists( $moduleName, $modules ) ) {
@@ -362,6 +362,9 @@ class ApiQuery extends ApiBase {
                        $vals = [];
                        ApiQueryBase::addTitleInfo( $vals, $title );
                        $vals['missing'] = true;
+                       if ( $title->isKnown() ) {
+                               $vals['known'] = true;
+                       }
                        $pages[$fakeId] = $vals;
                }
                // Report any invalid titles
@@ -372,7 +375,7 @@ class ApiQuery extends ApiBase {
                foreach ( $pageSet->getMissingPageIDs() as $pageid ) {
                        $pages[$pageid] = [
                                'pageid' => $pageid,
-                               'missing' => true
+                               'missing' => true,
                        ];
                }
                // Report special pages
@@ -381,13 +384,7 @@ class ApiQuery extends ApiBase {
                        $vals = [];
                        ApiQueryBase::addTitleInfo( $vals, $title );
                        $vals['special'] = true;
-                       if ( $title->isSpecialPage() &&
-                               !SpecialPageFactory::exists( $title->getDBkey() )
-                       ) {
-                               $vals['missing'] = true;
-                       } elseif ( $title->getNamespace() == NS_MEDIA &&
-                               !wfFindFile( $title )
-                       ) {
+                       if ( !$title->isKnown() ) {
                                $vals['missing'] = true;
                        }
                        $pages[$fakeId] = $vals;
@@ -418,11 +415,7 @@ class ApiQuery extends ApiBase {
                }
 
                if ( !$fit ) {
-                       $this->dieUsage(
-                               'The value of $wgAPIMaxResultSize on this wiki is ' .
-                                       'too small to hold basic result information',
-                               'badconfig'
-                       );
+                       $this->dieWithError( 'apierror-badconfig-resulttoosmall', 'badconfig' );
                }
 
                if ( $this->mParams['export'] ) {