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

SVN:trunk[3773]
This commit is contained in:
Denis Flaven
2015-09-17 17:00:56 +00:00
parent 48ab835646
commit 1206cc42bc
2 changed files with 22 additions and 4 deletions

View File

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

View File

@@ -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)."');");
}