From: Sam Reed Date: Thu, 3 Mar 2011 23:22:39 +0000 (+0000) Subject: Followup r82060 X-Git-Tag: 1.31.0-rc.0~31666 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=01caf960f294e26335f1d0c3a737d08b9d591357;p=lhc%2Fweb%2Fwiklou.git Followup r82060 Calling intval() on an array of integers isn't going to get people very far simplify logic, and then only do validation if $min or $max are not null --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 141d11c223..26bb18c835 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -727,18 +727,18 @@ abstract class ApiBase { $enforceLimits = isset ( $paramSettings[self::PARAM_RANGE_ENFORCE] ) ? $paramSettings[self::PARAM_RANGE_ENFORCE] : false; - if ( !is_null( $min ) || !is_null( $max ) ) { - if ( is_array( $value ) ) { - $value = array_map( 'intval', $value ); + if ( is_array( $value ) ) { + $value = array_map( 'intval', $value ); + if ( !is_null( $min ) || !is_null( $max ) ) { foreach ( $value as &$v ) { $this->validateLimit( $paramName, $v, $min, $max, null, $enforceLimits ); } - } else { - $value = intval( $value ); - $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits ); } } else { $value = intval( $value ); + if ( !is_null( $min ) || !is_null( $max ) ) { + $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits ); + } } break; case 'limit':