Adding array_filter() to remove empty conditions that can be caused by array casting an empty string.

This commit is contained in:
Mark Story 2010-03-15 22:15:03 -04:00
parent daf02cad61
commit 190066fd51

View file

@ -1370,10 +1370,10 @@ class Model extends Overloadable {
}
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,