r72979 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72978‎ | r72979 | r72980 >
Date:15:13, 14 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.4 - Fixed regression in InRange criterion
Modified paths:
  • /trunk/extensions/Validator/includes/criteria/CriterionInRange.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/criteria/CriterionInRange.php
@@ -13,14 +13,29 @@
1414 */
1515 class CriterionInRange extends ItemParameterCriterion {
1616
 17+ /**
 18+ * Lower bound of the range. Either a number or false, for no lower limit.
 19+ *
 20+ * @since 0.4
 21+ *
 22+ * @var mixed
 23+ */
1724 protected $lowerBound;
 25+
 26+ /**
 27+ * Upper bound of the range. Either a number or false, for no upper limit.
 28+ *
 29+ * @since 0.4
 30+ *
 31+ * @var mixed
 32+ */
1833 protected $upperBound;
1934
2035 /**
2136 * Constructor.
2237 *
23 - * @param integer $lowerBound
24 - * @param integer $upperBound
 38+ * @param mixed $lowerBound
 39+ * @param mixed $upperBound
2540 *
2641 * @since 0.4
2742 */
@@ -35,13 +50,14 @@
3651 * @see ItemParameterCriterion::validate
3752 */
3853 protected function doValidation( $value ) {
39 - if ( ! is_numeric( $value ) ) {
 54+ if ( !is_numeric( $value ) ) {
4055 return false;
4156 }
4257
4358 $value = (int)$value;
4459
45 - return $value <= $this->upperBound && $value >= $this->lowerBound;
 60+ return ( $this->upperBound === false || $value <= $this->upperBound )
 61+ && ( $this->lowerBound === false || $value >= $this->lowerBound );
4662 }
4763
4864 /**

Status & tagging log