From 50b3893e6507979427e1aaeb435494aed1af4f52 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Oct 2014 17:59:31 -0400 Subject: [PATCH] Make rule sniff less complicated and tidy up doc block. Refs #4871 --- lib/Cake/Model/Model.php | 8 ++++++-- lib/Cake/Test/Case/Model/ModelValidationTest.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 3a908f5df..4ae591015 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -3302,8 +3302,12 @@ class Model extends Object implements CakeEventListener { */ public function isUnique($fields, $or = true) { if (is_array($or)) { - $isAssociative = count(array_filter(array_keys($or), 'is_string')); - if (!$isAssociative) { + $isRule = ( + array_key_exists('rule', $or) && + array_key_exists('required', $or) && + array_key_exists('message', $or) + ); + if (!$isRule) { $args = func_get_args(); $fields = $args[1]; $or = isset($args[2]) ? $args[2] : true; diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 270d61119..e25f87897 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -2450,7 +2450,7 @@ class ModelValidationTest extends BaseModelTest { } /** - * Test backward compatibility of the isUnique method when used as a validator for multiple fields. + * Test backward compatibility of the isUnique method when used as a validator for a single field. * * @return void */