From cc88680d172e5372308bb7ee950975b6fd206001 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 13 Jan 2009 18:41:04 +0000 Subject: [PATCH] Adding array cast to $check. Fixes issues when non arrays are validated with Validation::multiple. Tests added. Fixes #5986 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7974 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/validation.php | 2 +- cake/tests/cases/libs/validation.test.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index db9d003c3..339d8668d 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -632,7 +632,7 @@ class Validation extends Object { function multiple($check, $options = array()) { $defaults = array('in' => null, 'max' => null, 'min' => null); $options = array_merge($defaults, $options); - $check = array_filter($check); + $check = array_filter((array)$check); if (empty($check)) { return false; } diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 0c9495d63..3f2c35c13 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -1782,6 +1782,8 @@ class ValidationTestCase extends CakeTestCase { $this->assertTrue(Validation::multiple(array(0, 1, 2, 3))); $this->assertTrue(Validation::multiple(array(50, 32, 22, 0))); $this->assertTrue(Validation::multiple(array('str', 'var', 'enum', 0))); + $this->assertFalse(Validation::multiple('')); + $this->assertFalse(Validation::multiple(null)); $this->assertFalse(Validation::multiple(array())); $this->assertFalse(Validation::multiple(array(0))); $this->assertFalse(Validation::multiple(array('0')));