Skip to content

Commit

Permalink
fix: delete cascading defined by relationships
Browse files Browse the repository at this point in the history
The bug is caused by the usage of the same variable name as function
input parameter and later as cycle variable, the latter replaces
original input parameter making remaining function code potentially
produce an error (even fatal error)
  • Loading branch information
kulbakin committed Oct 20, 2013
1 parent d0df251 commit 820fa07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libraries/anahita/domain/space/state.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ protected function _validateDelete($entity)
if ( $relationship->isOneToOne() )
$entities = array($entities);

foreach($entities as $entity)
foreach($entities as $ent)
{
//if the cascading fails for the related entities then
//nullify the property in the failed entity
if ( !$entity->delete() )
$entity->set($relationship->getChildKey(), null);
if ( !$ent->delete() )
$ent->set($relationship->getChildKey(), null);
}
}

Expand Down

0 comments on commit 820fa07

Please sign in to comment.