ApiMain::reportUnusedParams() is called before the XML formatter is
executed, so using "includexmlnamespace" or another such parameter
causes the incorrect generation of a warning. This patch corrects
the issue by explicitly excluding valid formatter parameters from
the list of unused parameters.
This does not need a release note because MediaWiki 1.20 did not
generate this kind of warning.
Change-Id: I269a6e07aa245099c811947d7832e1aa6fcfb9ec
$paramsUsed = $this->getParamsUsed();
$allParams = $this->getRequest()->getValueNames();
$paramsUsed = $this->getParamsUsed();
$allParams = $this->getRequest()->getValueNames();
- $unusedParams = array_diff( $allParams, $paramsUsed );
+ // Printer has not yet executed; don't warn that its parameters are unused
+ $printerParams = array_map(
+ array( $this->mPrinter, 'encodeParamName' ),
+ array_keys( $this->mPrinter->getFinalParams() ?: array() )
+ );
+
+ $unusedParams = array_diff( $allParams, $paramsUsed, $printerParams );
if( count( $unusedParams ) ) {
$s = count( $unusedParams ) > 1 ? 's' : '';
$this->setWarning( "Unrecognized parameter$s: '" . implode( $unusedParams, "', '" ) . "'" );
if( count( $unusedParams ) ) {
$s = count( $unusedParams ) > 1 ? 's' : '';
$this->setWarning( "Unrecognized parameter$s: '" . implode( $unusedParams, "', '" ) . "'" );