From e698891d09dc834d49626ba768ad4407fbb582d3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Mar 2017 21:29:44 -0500 Subject: [PATCH] Hash::filter() should not exclude 0.0 Refs #10385 --- lib/Cake/Test/Case/Utility/HashTest.php | 17 +++++++++++++++-- lib/Cake/Utility/Hash.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 5618ddc8b..74954b6a0 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -655,8 +655,21 @@ class HashTest extends CakeTestCase { * @return void */ public function testFilter() { - $result = Hash::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false))); - $expected = array('0', 2 => true, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be')); + $result = Hash::filter(array( + '0', + false, + true, + 0, + 0.0, + array('one thing', 'I can tell you', 'is you got to be', false) + )); + $expected = array( + '0', + 2 => true, + 3 => 0, + 4 => 0.0, + 5 => array('one thing', 'I can tell you', 'is you got to be') + ); $this->assertSame($expected, $result); $result = Hash::filter(array(1, array(false))); diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index cdc564784..258fbdf67 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -573,7 +573,7 @@ class Hash { * @return bool */ protected static function _filter($var) { - if ($var === 0 || $var === '0' || !empty($var)) { + if ($var === 0 || $var === 0.0 || $var === '0' || !empty($var)) { return true; } return false;