Fixed Trac# 457: crash when deleting two organizations.

SVN:trunk[1482]
This commit is contained in:
Denis Flaven
2011-08-19 17:14:06 +00:00
parent 266135b1b9
commit 6c8e021727
2 changed files with 10 additions and 3 deletions

View File

@@ -1396,7 +1396,7 @@ abstract class DBObject
{
// Update the left & right indexes for each hierarchical key
$sTable = $sTable = MetaModel::DBGetTable(get_class($this), $sAttCode);
$sSQL = "SELECT `".$oAttDef->GetSQLRight()."` AS `right`, `".$oAttDef->GetSQLLeft()."` AS `left` FROM `$sTable` WHERE id=".$this->GetKey();
$sSQL = "SELECT `".$oAttDef->GetSQLRight()."` AS `right`, `".$oAttDef->GetSQLLeft()."` AS `left` FROM `$sTable` WHERE id=".CMDBSource::Quote($this->m_iKey);
$aRes = CMDBSource::QueryToArray($sSQL);
$iMyLeft = $aRes[0]['left'];
$iMyRight = $aRes[0]['right'];
@@ -1453,7 +1453,14 @@ abstract class DBObject
foreach ($aToDelete as $iId => $aData)
{
$oToDelete = $aData['to_delete'];
$oToDelete->DBDeleteSingleObject();
// The deletion based on a deletion plan should not be done for each oject if the deletion plan is common (Trac #457)
// because for each object we would try to update all the preceding ones... that are already deleted
// A better approach would be to change the API to apply the DBDelete on the deletion plan itself... just once
// As a temporary fix: delete only the objects that are still to be deleted...
if ($oToDelete->m_bIsInDB)
{
$oToDelete->DBDeleteSingleObject();
}
}
}

View File

@@ -94,7 +94,7 @@ function DeleteObjects(WebPage $oP, $sClass, $aObjects, $bDeleteConfirmed)
}
$aDisplayData[] = array(
'class' => MetaModel::GetName(get_class($oToDelete)),
'object' => $oToDelete->GetHyperLink(),
'object' => $oToDelete->GetName(),
'consequence' => $sMessage,
);
}