From 190066fd51c222de91989aec97b0042d7bcda7c9 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 15 Mar 2010 22:15:03 -0400 Subject: [PATCH] Adding array_filter() to remove empty conditions that can be caused by array casting an empty string. --- cake/libs/model/model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index d76510fc8..c0ad6aaa1 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -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, @@ -1397,7 +1397,7 @@ class Model extends Overloadable { } if (!empty($newValues)) { - $fields = implode(',', $fields); + $fields = implode(',', $fields); $db->insertMulti($this->{$join}, $fields, $newValues); } }