Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/126990
Change subject: API: Warn when unsupported PHP array syntax is used
......................................................................
API: Warn when unsupported PHP array syntax is used
The API takes multi-valued parameters as key=value1|value2|value3, not
key[]=value1&key[]=value2&key[]=value3, in part because the latter is
overly verbose when the API encourages use of large arrays.
But when someone, not knowing this, does accidentally use the verbose
syntax, they should get a warning instead of having the parameter be
silently ignored.
Bug: 64057
Change-Id: I32a16efb8028d7f6d120d20dfc886f08ed9ec97d
---
M includes/api/ApiMain.php
1 file changed, 13 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/90/126990/1
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 2e16312..5cdcd51 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -980,7 +980,18 @@
public function getVal( $name, $default = null ) {
$this->mParamsUsed[$name] = true;
- return $this->getRequest()->getVal( $name, $default );
+ $ret = $this->getRequest()->getVal( $name );
+ if ( $ret === null ) {
+ if ( $this->getRequest()->getArray( $name ) !== null ) {
+ // See bug 10262 for why we don't just join(
'|', ... ) the
+ // array.
+ $this->setWarning(
+ "Parameter '$name' uses unsupported PHP
array syntax"
+ );
+ }
+ $ret = $default;
+ }
+ return $ret;
}
/**
@@ -988,9 +999,7 @@
* was used, for logging.
*/
public function getCheck( $name ) {
- $this->mParamsUsed[$name] = true;
-
- return $this->getRequest()->getCheck( $name );
+ return $this->getVal( $name, null ) !== null;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/126990
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I32a16efb8028d7f6d120d20dfc886f08ed9ec97d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits