mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing issues with plugin models used in habtm 'with' keys. Fixes #1548
This commit is contained in:
parent
9ae8dcafdc
commit
6d2b31d4d1
2 changed files with 18 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue