Fix Hash::extract() not matching 1/0 to true/false.

Historically [prop=1] has matched prop=true as well. This restores that
and also fixes [prop=0] not finding falsey values.

This makes the typing less strict in Hash::extract() but I don't think
it is unreasonable given PHP's type juggling.

Refs #3288
This commit is contained in:
mark_story 2014-06-12 11:30:48 -04:00
parent d8b4c3967c
commit fa19c34580
2 changed files with 13 additions and 1 deletions

View file

@ -208,7 +208,10 @@ class Hash {
if (isset($data[$attr])) {
$prop = $data[$attr];
}
if ($prop === true || $prop === false) {
$isBool = is_bool($prop);
if ($isBool && is_numeric($val)) {
$prop = $prop ? '1' : '0';
} elseif ($isBool) {
$prop = $prop ? 'true' : 'false';
}