From 931d996d9001bcc3c130efac6fe853f73903e955 Mon Sep 17 00:00:00 2001 From: gwoo Date: Fri, 19 Sep 2008 15:27:43 +0000 Subject: [PATCH] fixes #5438, multiple binding with alias git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7632 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/model.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 0fc58c809..ba91540d7 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -593,7 +593,7 @@ class Model extends Overloadable { $className = $assoc; } - if (!isset($this->{$assoc})) { + if (!isset($this->{$assoc}) || $this->{$assoc}->name !== $className) { $model = array('class' => $className, 'alias' => $assoc); if (PHP5) { $this->{$assoc} = ClassRegistry::init($model); @@ -1326,7 +1326,7 @@ class Model extends Overloadable { if (!$currentValidates = $this->__save($this, $record, $options)) { $validationErrors[$key] = $this->validationErrors; } - + if ($options['validate'] === 'only' || $options['validate'] === 'first') { $validating = true; if ($options['atomic']) { @@ -1338,7 +1338,7 @@ class Model extends Overloadable { $validating = false; $validates = $currentValidates; } - + if (!$options['atomic']) { $return[] = $validates; } elseif (!$validates && !$validating) { @@ -2234,7 +2234,7 @@ class Model extends Overloadable { !is_numeric($data[$fieldName])) && $validator['allowEmpty'] === false ) ); - + if ($required) { $this->invalidate($fieldName, $message); if ($validator['last']) {