r74234 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74233‎ | r74234 | r74235 >
Date:20:29, 3 October 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Minor tweaks to r74232, add a value for $botMax on calls for integer validation (otherwise the bool gets pushed into it!)

Documentation in ApiDelete
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiDelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiDelete.php
@@ -97,6 +97,11 @@
9898 $this->getResult()->addValue( null, $this->getModuleName(), $r );
9999 }
100100
 101+ /**
 102+ *
 103+ * @param &$title Title
 104+ * @param $token String
 105+ */
101106 private static function getPermissionsError( &$title, $token ) {
102107 global $wgUser;
103108
Index: trunk/phase3/includes/api/ApiBase.php
@@ -677,8 +677,6 @@
678678
679679 break;
680680 case 'integer': // Force everything using intval() and optionally validate limits
681 - $value = is_array( $value ) ? array_map( 'intval', $value ) : intval( $value );
682 -
683681 $min = isset ( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : null;
684682 $max = isset ( $paramSettings[self::PARAM_MAX] ) ? $paramSettings[self::PARAM_MAX] : null;
685683 $enforceLimits = isset ( $paramSettings[self::PARAM_RANGE_ENFORCE] )
@@ -686,11 +684,13 @@
687685
688686 if ( !is_null( $min ) || !is_null( $max ) ) {
689687 if ( is_array( $value ) ) {
 688+ $value = array_map( 'intval', $value );
690689 foreach ( $value as &$v ) {
691 - $this->validateLimit( $paramName, $v, $min, $max, $enforceLimits );
 690+ $this->validateLimit( $paramName, $v, $min, $max, null, $enforceLimits );
692691 }
693692 } else {
694 - $this->validateLimit( $paramName, $value, $min, $max, $enforceLimits );
 693+ $value = intval( $value );
 694+ $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits );
695695 }
696696 }
697697 break;
@@ -866,7 +866,7 @@
867867 */
868868 private function warnOrDie( $msg, $enforceLimits = false ) {
869869 if ( $enforceLimits ) {
870 - $this->dieUsageMsg( $msg );
 870+ $this->dieUsage( 'integeroutofrange', $msg );
871871 } else {
872872 $this->setWarning( $msg );
873873 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r74279Followup r74234 flip parametersreedy21:18, 4 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74232Followup r74230, if we make things array, we should make them not an array af...reedy20:07, 3 October 2010

Comments

#Comment by Catrope (talk | contribs)   09:09, 4 October 2010
+			$this->dieUsage( 'integeroutofrange', $msg );

You're using dieUsage() backwards here: it's dieUsage( $description, $errorCode )

Status & tagging log