XML format: fix "Unrecognized parameter" warning
authorKevin Israel <pleasestand@live.com>
Sat, 23 Feb 2013 21:19:29 +0000 (16:19 -0500)
committerKevin Israel <pleasestand@live.com>
Sat, 23 Feb 2013 21:19:29 +0000 (16:19 -0500)
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

includes/api/ApiMain.php

index fed515b..c3ae8b1 100644 (file)
@@ -921,7 +921,13 @@ class ApiMain extends ApiBase {
                $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, "', '" ) . "'" );