diff --git a/core/deletionplan.class.inc.php b/core/deletionplan.class.inc.php index 10413cd30..3f0d5d68d 100644 --- a/core/deletionplan.class.inc.php +++ b/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; } diff --git a/pages/UI.php b/pages/UI.php index d2f09514a..1821b9aa3 100644 --- a/pages/UI.php +++ b/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)."');"); }