X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiPageSet.php;h=160ce87365f7eafb4fe66c165e231bc867739ebb;hb=dfaa26a7b19ab65190a76cd32259a3637cc3e2fd;hp=46c57b86b4d244ad38fb4100c1ca5976e8836755;hpb=72b9240497311a2fa5f5b76d9e8bb953dc59853f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 46c57b86b4..160ce87365 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -23,6 +23,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; /** * This class contains a list of pages that the client has requested. @@ -154,10 +155,10 @@ class ApiPageSet extends ApiBase { } $generator = $dbSource->getModuleManager()->getModule( $generatorName, null, true ); if ( $generator === null ) { - $this->dieUsage( 'Unknown generator=' . $generatorName, 'badgenerator' ); + $this->dieWithError( [ 'apierror-badgenerator-unknown', $generatorName ], 'badgenerator' ); } if ( !$generator instanceof ApiQueryGeneratorBase ) { - $this->dieUsage( "Module $generatorName cannot be used as a generator", 'badgenerator' ); + $this->dieWithError( [ 'apierror-badgenerator-notgenerator', $generatorName ], 'badgenerator' ); } // Create a temporary pageset to store generator's output, // add any additional fields generator may need, and execute pageset to populate titles/pageids @@ -193,13 +194,27 @@ class ApiPageSet extends ApiBase { } if ( isset( $this->mParams['pageids'] ) ) { if ( isset( $dataSource ) ) { - $this->dieUsage( "Cannot use 'pageids' at the same time as '$dataSource'", 'multisource' ); + $this->dieWithError( + [ + 'apierror-invalidparammix-cannotusewith', + $this->encodeParamName( 'pageids' ), + $this->encodeParamName( $dataSource ) + ], + 'multisource' + ); } $dataSource = 'pageids'; } if ( isset( $this->mParams['revids'] ) ) { if ( isset( $dataSource ) ) { - $this->dieUsage( "Cannot use 'revids' at the same time as '$dataSource'", 'multisource' ); + $this->dieWithError( + [ + 'apierror-invalidparammix-cannotusewith', + $this->encodeParamName( 'revids' ), + $this->encodeParamName( $dataSource ) + ], + 'multisource' + ); } $dataSource = 'revids'; } @@ -215,9 +230,7 @@ class ApiPageSet extends ApiBase { break; case 'revids': if ( $this->mResolveRedirects ) { - $this->setWarning( 'Redirect resolution cannot be used ' . - 'together with the revids= parameter. Any redirects ' . - 'the revids= point to have not been resolved.' ); + $this->addWarning( 'apiwarn-redirectsandrevids' ); } $this->mResolveRedirects = false; $this->initFromRevIDs( $this->mParams['revids'] ); @@ -915,7 +928,7 @@ class ApiPageSet extends ApiBase { } // Get gender information - $genderCache = GenderCache::singleton(); + $genderCache = MediaWikiServices::getInstance()->getGenderCache(); $genderCache->doQuery( $usernames, __METHOD__ ); } @@ -1138,7 +1151,7 @@ class ApiPageSet extends ApiBase { $this->mAllPages[0][$title] = $this->mFakePageId; $this->mInvalidTitles[$this->mFakePageId] = [ 'title' => $title, - 'invalidreason' => $ex->getMessage(), + 'invalidreason' => $this->getErrorFormatter()->formatException( $ex, [ 'bc' => true ] ), ]; $this->mFakePageId--; continue; // There's nothing else we can do @@ -1197,7 +1210,7 @@ class ApiPageSet extends ApiBase { } } // Get gender information - $genderCache = GenderCache::singleton(); + $genderCache = MediaWikiServices::getInstance()->getGenderCache(); $genderCache->doQuery( $usernames, __METHOD__ ); return $linkBatch; @@ -1411,13 +1424,7 @@ class ApiPageSet extends ApiBase { ApiBase::PARAM_DFLT => false, ApiBase::PARAM_HELP_MSG => [ 'api-pageset-param-converttitles', - new DeferredStringifier( - function ( IContextSource $context ) { - return $context->getLanguage() - ->commaList( LanguageConverter::$languagesWithVariants ); - }, - $this - ) + [ Message::listParam( LanguageConverter::$languagesWithVariants, 'text' ) ], ], ], ];