Prevent a crash when deleting objects accessed from a list of their abstract class (i.e. Select some Contacts, "delete...", select a Person, delete => crash).

SVN:trunk[2420]
This commit is contained in:
Denis Flaven
2012-11-12 14:23:24 +00:00
parent b22c23dfee
commit 71d011b7f8

View File

@@ -1653,10 +1653,11 @@ abstract class DBObject
protected function DBDeleteSingleObject()
{
$this->OnDelete();
if (!MetaModel::DBIsReadOnly())
{
$this->OnDelete();
$this->RecordObjDeletion($this->m_iKey); // May cause a reload for storing history information
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
{
if ($oAttDef->IsHierarchicalKey())
@@ -1689,14 +1690,12 @@ abstract class DBObject
{
$this->DBDeleteSingleTable($sParentClass);
}
$this->AfterDelete();
$this->m_bIsInDB = false;
$this->m_iKey = null;
}
$this->AfterDelete();
$this->RecordObjDeletion($this->m_iKey);
$this->m_bIsInDB = false;
$this->m_iKey = null;
}
// Delete an object... and guarantee data integrity