r83178 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83177‎ | r83178 | r83179 >
Date:23:22, 3 March 2011
Author:reedy
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBase.php
@@ -727,18 +727,18 @@
728728 $enforceLimits = isset ( $paramSettings[self::PARAM_RANGE_ENFORCE] )
729729 ? $paramSettings[self::PARAM_RANGE_ENFORCE] : false;
730730
731 - if ( !is_null( $min ) || !is_null( $max ) ) {
732 - if ( is_array( $value ) ) {
733 - $value = array_map( 'intval', $value );
 731+ if ( is_array( $value ) ) {
 732+ $value = array_map( 'intval', $value );
 733+ if ( !is_null( $min ) || !is_null( $max ) ) {
734734 foreach ( $value as &$v ) {
735735 $this->validateLimit( $paramName, $v, $min, $max, null, $enforceLimits );
736736 }
737 - } else {
738 - $value = intval( $value );
739 - $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits );
740737 }
741738 } else {
742739 $value = intval( $value );
 740+ if ( !is_null( $min ) || !is_null( $max ) ) {
 741+ $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits );
 742+ }
743743 }
744744 break;
745745 case 'limit':

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82060* (bug 27376) when using ApiBase::PARAM_TYPE => 'integer' without a min or ma...reedy17:00, 13 February 2011

Status & tagging log