Преглед изворни кода

#1151 Error (with no explanation) when deleting some 1-N links

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3773 a333f486-631f-4898-b8df-5754b55c2be0
dflaven пре 9 година
родитељ
комит
652a61e5c1
2 измењених фајлова са 22 додато и 4 уклоњено
  1. 1 0
      core/deletionplan.class.inc.php
  2. 21 4
      pages/UI.php

+ 1 - 0
core/deletionplan.class.inc.php

@@ -101,6 +101,7 @@ class DeletionPlan
 				}
 				if ($aData['mode'] == DEL_MANUAL)
 				{
+					$this->m_aToDelete[$sClass][$iId]['issue'] = $sClass.'::'.$iId.' '.Dict::S('UI:Delete:MustBeDeletedManually');
 					$this->m_bFoundStopper = true;
 					$this->m_bFoundManualDelete = true;
 				}

+ 21 - 4
pages/UI.php

@@ -778,18 +778,35 @@ EOF
 					list($bRes, $aIssues) = $oObj->CheckToWrite();
 					if ($bRes)
 					{
-						$oObj->DBUpdate();
+						try
+						{
+							CMDBSource::Query('START TRANSACTION');
+							$oObj->DBUpdate();
+							CMDBSource::Query('COMMIT');
+							$sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
+							$sSeverity = 'ok';
+						}
+						catch(DeleteException $e)
+						{
+							CMDBSource::Query('ROLLBACK');
+							// Say two things: 1) Don't be afraid nothing was modified
+							$sMessage = Dict::Format('UI:Class_Object_NotUpdated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
+							$sSeverity = 'info';
+							cmdbAbstractObject::SetSessionMessage(get_class($oObj), $oObj->GetKey(), 'UI:Class_Object_NotUpdated', $sMessage, $sSeverity, 0, true /* must not exist */);
+							// 2) Ok, there was some trouble indeed	
+							$sMessage = $e->getMessage();
+							$sSeverity = 'error';
+							$bDisplayDetails = true;
+						}
 						utils::RemoveTransaction($sTransactionId);
 			
-						$sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
-						$sSeverity = 'ok';
 					}
 					else
 					{
 						$bDisplayDetails = false;
 						// Found issues, explain and give the user a second chance
 						//
-						$oObj->DisplayModifyForm($oP, array('wizard_container' => true), $sToken); // wizard_container: display the wizard border and the title
+						$oObj->DisplayModifyForm($oP, array('wizard_container' => true)); // wizard_container: display the wizard border and the title
 						$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues));
 						$oP->add_ready_script("alert('".addslashes($sIssueDesc)."');");
 					}