Make rule sniff less complicated and tidy up doc block.

Refs #4871
This commit is contained in:
mark_story 2014-10-13 17:59:31 -04:00
parent 1ded0c21dd
commit 50b3893e65
2 changed files with 7 additions and 3 deletions

View file

@ -3302,8 +3302,12 @@ class Model extends Object implements CakeEventListener {
*/ */
public function isUnique($fields, $or = true) { public function isUnique($fields, $or = true) {
if (is_array($or)) { if (is_array($or)) {
$isAssociative = count(array_filter(array_keys($or), 'is_string')); $isRule = (
if (!$isAssociative) { array_key_exists('rule', $or) &&
array_key_exists('required', $or) &&
array_key_exists('message', $or)
);
if (!$isRule) {
$args = func_get_args(); $args = func_get_args();
$fields = $args[1]; $fields = $args[1];
$or = isset($args[2]) ? $args[2] : true; $or = isset($args[2]) ? $args[2] : true;

View file

@ -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 * @return void
*/ */