mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 07:42:17 +02:00
🎨 \DBObject::DBDeleteSingleObject : isolate exit condition at the top
This commit is contained in:
@@ -3254,14 +3254,18 @@ abstract class DBObject implements iDisplay
|
|||||||
*/
|
*/
|
||||||
protected function DBDeleteSingleObject()
|
protected function DBDeleteSingleObject()
|
||||||
{
|
{
|
||||||
if (!MetaModel::DBIsReadOnly())
|
if (MetaModel::DBIsReadOnly())
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->OnDelete();
|
$this->OnDelete();
|
||||||
|
|
||||||
// Activate any existing trigger
|
// Activate any existing trigger
|
||||||
$sClass = get_class($this);
|
$sClass = get_class($this);
|
||||||
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
|
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
|
||||||
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectDelete AS t WHERE t.target_class IN (:class_list)"), array(), $aParams);
|
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectDelete AS t WHERE t.target_class IN (:class_list)"), array(),
|
||||||
|
$aParams);
|
||||||
while ($oTrigger = $oSet->Fetch())
|
while ($oTrigger = $oSet->Fetch())
|
||||||
{
|
{
|
||||||
/** @var \Trigger $oTrigger */
|
/** @var \Trigger $oTrigger */
|
||||||
@@ -3270,7 +3274,7 @@ abstract class DBObject implements iDisplay
|
|||||||
|
|
||||||
$this->RecordObjDeletion($this->m_iKey); // May cause a reload for storing history information
|
$this->RecordObjDeletion($this->m_iKey); // May cause a reload for storing history information
|
||||||
|
|
||||||
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
|
foreach (MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
|
||||||
{
|
{
|
||||||
if ($oAttDef->IsHierarchicalKey())
|
if ($oAttDef->IsHierarchicalKey())
|
||||||
{
|
{
|
||||||
@@ -3281,7 +3285,7 @@ abstract class DBObject implements iDisplay
|
|||||||
$aRes = CMDBSource::QueryToArray($sSQL);
|
$aRes = CMDBSource::QueryToArray($sSQL);
|
||||||
$iMyLeft = $aRes[0]['left'];
|
$iMyLeft = $aRes[0]['left'];
|
||||||
$iMyRight = $aRes[0]['right'];
|
$iMyRight = $aRes[0]['right'];
|
||||||
$iDelta =$iMyRight - $iMyLeft + 1;
|
$iDelta = $iMyRight - $iMyLeft + 1;
|
||||||
MetaModel::HKTemporaryCutBranch($iMyLeft, $iMyRight, $oAttDef, $sTable);
|
MetaModel::HKTemporaryCutBranch($iMyLeft, $iMyRight, $oAttDef, $sTable);
|
||||||
|
|
||||||
// No new parent for now, insert completely at the right of the tree
|
// No new parent for now, insert completely at the right of the tree
|
||||||
@@ -3293,7 +3297,7 @@ abstract class DBObject implements iDisplay
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$iNewLeft = $aRes[0]['max']+1;
|
$iNewLeft = $aRes[0]['max'] + 1;
|
||||||
}
|
}
|
||||||
MetaModel::HKReplugBranch($iNewLeft, $iNewLeft + $iDelta - 1, $oAttDef, $sTable);
|
MetaModel::HKReplugBranch($iNewLeft, $iNewLeft + $iDelta - 1, $oAttDef, $sTable);
|
||||||
}
|
}
|
||||||
@@ -3304,7 +3308,7 @@ abstract class DBObject implements iDisplay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(MetaModel::EnumParentClasses(get_class($this), ENUM_PARENT_CLASSES_ALL) as $sParentClass)
|
foreach (MetaModel::EnumParentClasses(get_class($this), ENUM_PARENT_CLASSES_ALL) as $sParentClass)
|
||||||
{
|
{
|
||||||
$this->DBDeleteSingleTable($sParentClass);
|
$this->DBDeleteSingleTable($sParentClass);
|
||||||
}
|
}
|
||||||
@@ -3316,7 +3320,6 @@ abstract class DBObject implements iDisplay
|
|||||||
// objects, reported as bug N°926)
|
// objects, reported as bug N°926)
|
||||||
// Thought the key is not reset, using DBInsert or DBWrite will create an object having the same characteristics and a new ID. DBUpdate is protected
|
// Thought the key is not reset, using DBInsert or DBWrite will create an object having the same characteristics and a new ID. DBUpdate is protected
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an object
|
* Delete an object
|
||||||
|
|||||||
Reference in New Issue
Block a user