From b7abaf019c3dd1b2e7fdb6946666544d2dcf76aa Mon Sep 17 00:00:00 2001 From: nate Date: Tue, 8 Jan 2008 06:29:51 +0000 Subject: [PATCH] Adding non-null association key fix in Model, and updating Model::isUnique() to account for current record, fixes #3859, closes #2032 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6336 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/model.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 595541604..d235c7da3 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -692,7 +692,7 @@ class Model extends Overloadable { $class = $assocKey; foreach ($this->__associationKeys[$type] as $key) { - if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] == null) { + if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] === null) { $data = ''; switch($key) { @@ -1221,13 +1221,14 @@ class Model extends Overloadable { $success = $created = false; } else { $created = true; - if (!empty($this->belongsTo)) { - $this->updateCounterCache(); - } } } } + if (!empty($this->belongsTo)) { + $this->updateCounterCache(array(), $created); + } + if (!empty($joined) && $success === true) { $this->__saveMulti($joined, $this->id); } @@ -1922,6 +1923,9 @@ class Model extends Overloadable { if ($or) { $fields = array('or' => $fields); } + if (!empty($this->id)) { + $fields[$this->alias . '.' . $this->primaryKey] = '!= ' . $this->id; + } return ($this->find('count', array('conditions' => $fields)) == 0); } /**