From: Mark A. Hershberger Date: Mon, 15 Feb 2010 07:06:49 +0000 (+0000) Subject: follow up r62353 Make ApiBase::requireOnlyOneParameter() accept parameters that are... X-Git-Tag: 1.31.0-rc.0~37757 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=26a4587d803632994f915700191067da8219cc99;p=lhc%2Fweb%2Fwiklou.git follow up r62353 Make ApiBase::requireOnlyOneParameter() accept parameters that are set, but false. This means that you can pass in more than one parameter, as long as it is the same as the default (false). Have to do it this way since we'd like to default boolean parameters to false in getAllowedParams() but by the time requireOnlyOneParameter() is called, the defaults are set, so we can't tell the difference between passing in a parameter set to the default and just getting the defaults. --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index a6a7a0a43b..ff54af1003 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -474,7 +474,7 @@ abstract class ApiBase { } /** - * Die if none or more than one of a certain set of parameters is set + * Die if none or more than one of a certain set of parameters is set and not false. * @param $params array of parameter names */ public function requireOnlyOneParameter( $params ) { @@ -482,7 +482,7 @@ abstract class ApiBase { array_shift( $required ); $intersection = array_intersect( array_keys( array_filter( $params, - create_function( '$x', 'return !is_null($x);' ) + create_function( '$x', 'return !is_null($x) && $x !== false;' ) ) ), $required ); if ( count( $intersection ) > 1 ) { $this->dieUsage( 'The parameters ' . implode( ', ', $intersection ) . ' can not be used together', 'invalidparammix' );