From 01caf960f294e26335f1d0c3a737d08b9d591357 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 3 Mar 2011 23:22:39 +0000 Subject: [PATCH] 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 --- includes/api/ApiBase.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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': -- 2.20.1