Browse Source

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).

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2420 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 năm trước cách đây
mục cha
commit
a3ec7d9034
1 tập tin đã thay đổi với 8 bổ sung9 xóa
  1. 8 9
      core/dbobject.class.php

+ 8 - 9
core/dbobject.class.php

@@ -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->RecordObjDeletion($this->m_iKey);
+			
+			$this->AfterDelete();
 
-		$this->m_bIsInDB = false;
-		$this->m_iKey = null;
+			$this->m_bIsInDB = false;
+			$this->m_iKey = null;
+		}
 	}
 
 	// Delete an object... and guarantee data integrity