Pārlūkot izejas kodu

Fixed Trac# 457: crash when deleting two organizations.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1482 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 gadi atpakaļ
vecāks
revīzija
6801975551
2 mainītis faili ar 10 papildinājumiem un 3 dzēšanām
  1. 9 2
      core/dbobject.class.php
  2. 1 1
      pages/UI.php

+ 9 - 2
core/dbobject.class.php

@@ -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();
+					}
 				}
 			}
 

+ 1 - 1
pages/UI.php

@@ -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,
 				);
 			}