Skip to content

Commit

Permalink
Adding array_filter() to remove empty conditions that can be caused b…
Browse files Browse the repository at this point in the history
…y array casting an empty string.
  • Loading branch information
markstory committed Mar 16, 2010
1 parent daf02ca commit 190066f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cake/libs/model/model.php
Expand Up @@ -1370,10 +1370,10 @@ function __saveMulti($joined, $id) {
}

if ($this->hasAndBelongsToMany[$assoc]['unique']) {
$conditions = array_merge(
$conditions = array_filter(array_merge(
array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id),
(array)$this->hasAndBelongsToMany[$assoc]['conditions']
);
));
$links = $this->{$join}->find('all', array(
'conditions' => $conditions,
'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0,
Expand All @@ -1397,7 +1397,7 @@ function __saveMulti($joined, $id) {
}

if (!empty($newValues)) {
$fields = implode(',', $fields);
$fields = implode(',', $fields);
$db->insertMulti($this->{$join}, $fields, $newValues);
}
}
Expand Down

0 comments on commit 190066f

Please sign in to comment.