X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiPageSet.php;h=160ce87365f7eafb4fe66c165e231bc867739ebb;hb=dfaa26a7b19ab65190a76cd32259a3637cc3e2fd;hp=1a509c5c1e0edb487b00b72d9ce86b2ad03d678b;hpb=ff70e103def9601f40836cbd9022e1267200510e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 1a509c5c1e..160ce87365 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -155,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 @@ -194,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'; } @@ -216,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'] ); @@ -1139,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 @@ -1412,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' ) ], ], ], ];