mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Separates derivation of conditions for cascaded deletion of HABTM records to a protected method #13046
This commit is contained in:
parent
c4a51509c5
commit
c14782305b
1 changed files with 14 additions and 1 deletions
|
@ -2801,7 +2801,7 @@ class Model extends CakeObject implements CakeEventListener {
|
||||||
list(, $joinModel) = pluginSplit($data['with']);
|
list(, $joinModel) = pluginSplit($data['with']);
|
||||||
$Model = $this->{$joinModel};
|
$Model = $this->{$joinModel};
|
||||||
$records = $Model->find('all', array(
|
$records = $Model->find('all', array(
|
||||||
'conditions' => array($Model->escapeField($data['foreignKey']) => $id),
|
'conditions' => $this->_getConditionsForDeletingLinks($Model, $id, $data),
|
||||||
'fields' => $Model->primaryKey,
|
'fields' => $Model->primaryKey,
|
||||||
'recursive' => -1,
|
'recursive' => -1,
|
||||||
'callbacks' => false
|
'callbacks' => false
|
||||||
|
@ -2815,6 +2815,19 @@ class Model extends CakeObject implements CakeEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the conditions to be applied to Model::find() when determining which HABTM records should be deleted via
|
||||||
|
* Model::_deleteLinks()
|
||||||
|
*
|
||||||
|
* @param Model $Model HABTM join model instance
|
||||||
|
* @param mixed $id The ID of the primary model which is being deleted
|
||||||
|
* @param array $relationshipConfig The relationship config defined on the primary model
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _getConditionsForDeletingLinks(Model $Model, $id, array $relationshipConfig) {
|
||||||
|
return array($Model->escapeField($relationshipConfig['foreignKey']) => $id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes multiple model records based on a set of conditions.
|
* Deletes multiple model records based on a set of conditions.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue