mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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
This commit is contained in:
parent
2c4a8f4131
commit
b7abaf019c
1 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue