diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index e5e0e4819..933153828 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1959,7 +1959,7 @@ class Model extends Object { */ protected function _deleteLinks($id) { foreach ($this->hasAndBelongsToMany as $assoc => $data) { - $joinModel = $data['with']; + list($plugin, $joinModel) = pluginSplit($data['with']); $records = $this->{$joinModel}->find('all', array( 'conditions' => array_merge(array($this->{$joinModel}->escapeField($data['foreignKey']) => $id)), 'fields' => $this->{$joinModel}->primaryKey, diff --git a/cake/tests/cases/libs/model/model_delete.test.php b/cake/tests/cases/libs/model/model_delete.test.php index 97535ad17..77c546fec 100644 --- a/cake/tests/cases/libs/model/model_delete.test.php +++ b/cake/tests/cases/libs/model/model_delete.test.php @@ -533,6 +533,23 @@ class ModelDeleteTest extends BaseModelTest { $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); } +/** + * test that a plugin model as the 'with' model doesn't have issues + * + * @return void + */ + function testDeleteLinksWithPLuginJoinModel() { + $this->loadFixtures('Article', 'ArticlesTag', 'Tag'); + $Article =& new Article(); + $Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')), false); + unset($Article->Tag, $Article->ArticleTags); + $Article->bindModel(array('hasAndBelongsToMany' => array( + 'Tag' => array('with' => 'TestPlugin.ArticlesTag') + )), false); + + $this->assertTrue($Article->delete(1)); + } + /** * test deleteLinks with Multiple habtm associations *