Skip to content

Commit

Permalink
Fixed bool cast to int when setting attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Vollstädt committed Jun 23, 2013
1 parent 3caaeb8 commit f7ca033
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions EMongoModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ public function setAttributes($values,$safeOnly=true)
$field_meta = isset($_meta[$name]) ? $_meta[$name] : array();
if($safeOnly){
if(isset($attributes[$name]))
$this->$name=!is_array($value) && preg_match('/^([0-9]|[1-9]{1}\d+)$/' /* Will only match real integers, unsigned */, $value) > 0
$this->$name=!is_bool($value) && !is_array($value) && preg_match('/^([0-9]|[1-9]{1}\d+)$/' /* Will only match real integers, unsigned */, $value) > 0
&& ( (PHP_INT_MAX > 2147483647 && (string)$value < '9223372036854775807') /* If it is a 64 bit system and the value is under the long max */
|| (string)$value < '2147483647' /* value is under 32bit limit */) ? (int)$value : $value;
elseif($safeOnly)
$this->onUnsafeAttribute($name,$value);
}else{
$this->$name=!is_array($value) && preg_match('/^([0-9]|[1-9]{1}\d+)$$/' /* Will only match real integers, unsigned */, $value) > 0
$this->$name=!is_bool($value) && !is_array($value) && preg_match('/^([0-9]|[1-9]{1}\d+)$$/' /* Will only match real integers, unsigned */, $value) > 0
&& ( (PHP_INT_MAX > 2147483647 && (string)$value < '9223372036854775807') || (string)$value < '2147483647') ? (int)$value : $value;
}
}
Expand Down Expand Up @@ -575,4 +575,4 @@ public function getJSONDocument(){
public function getBSONDocument(){
return bson_encode($this->getRawDocument());
}
}
}

0 comments on commit f7ca033

Please sign in to comment.