mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding fix for Ticket #1626.
This fixes deleting of associated hasOne and hasMany when using bindModel before Model::delete() git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3941 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2e0ec28018
commit
fd65f226e6
1 changed files with 14 additions and 0 deletions
|
@ -1159,6 +1159,10 @@ class Model extends Overloadable {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _deleteHasMany($id, $cascade) {
|
function _deleteHasMany($id, $cascade) {
|
||||||
|
if (isset($this->__backAssociation)) {
|
||||||
|
$savedAssociatons = $this->__backAssociation;
|
||||||
|
unset ($this->__backAssociation);
|
||||||
|
}
|
||||||
foreach($this->hasMany as $assoc => $data) {
|
foreach($this->hasMany as $assoc => $data) {
|
||||||
if ($data['dependent'] === true && $cascade === true) {
|
if ($data['dependent'] === true && $cascade === true) {
|
||||||
$model =& $this->{$data['className']};
|
$model =& $this->{$data['className']};
|
||||||
|
@ -1173,6 +1177,9 @@ class Model extends Overloadable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($savedAssociatons)) {
|
||||||
|
$this->__backAssociation = $savedAssociatons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Cascades model deletes to hasOne relationships.
|
* Cascades model deletes to hasOne relationships.
|
||||||
|
@ -1182,6 +1189,10 @@ class Model extends Overloadable {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _deleteHasOne($id, $cascade) {
|
function _deleteHasOne($id, $cascade) {
|
||||||
|
if (isset($this->__backAssociation)) {
|
||||||
|
$savedAssociatons = $this->__backAssociation;
|
||||||
|
unset ($this->__backAssociation);
|
||||||
|
}
|
||||||
foreach($this->hasOne as $assoc => $data) {
|
foreach($this->hasOne as $assoc => $data) {
|
||||||
if ($data['dependent'] === true && $cascade === true) {
|
if ($data['dependent'] === true && $cascade === true) {
|
||||||
$model =& $this->{$data['className']};
|
$model =& $this->{$data['className']};
|
||||||
|
@ -1196,6 +1207,9 @@ class Model extends Overloadable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($savedAssociatons)) {
|
||||||
|
$this->__backAssociation = $savedAssociatons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Cascades model deletes to HABTM join keys.
|
* Cascades model deletes to HABTM join keys.
|
||||||
|
|
Loading…
Add table
Reference in a new issue