From e4e5f627c4b1734bae5ae6ce3475e4f9b9280c80 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 4 Dec 2018 15:51:13 +0100 Subject: [PATCH] Display error log if UpdateObjectFromPostedForm fails when modifying an object in console --- pages/UI.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/UI.php b/pages/UI.php index 12e420907..8a70fb3ac 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -905,11 +905,11 @@ EOF } else { - $oObj->UpdateObjectFromPostedForm(); + $aErrors = $oObj->UpdateObjectFromPostedForm(); $sMessage = ''; $sSeverity = 'ok'; - if (!$oObj->IsModified()) + if (!$oObj->IsModified() && empty($aErrors)) { $oP->set_title(Dict::Format('UI:ModificationPageTitle_Object_Class', $oObj->GetRawName(), $sClassLabel)); // Set title will take care of the encoding $sMessage = Dict::Format('UI:Class_Object_NotUpdated', MetaModel::GetName(get_class($oObj)), $oObj->GetName()); @@ -920,6 +920,10 @@ EOF try { CMDBSource::Query('START TRANSACTION'); + if (!empty($aErrors)) + { + throw new CoreCannotSaveObjectException(array('id' => $oObj->GetKey(), 'class' => $sClass, 'issues' => $aErrors)); + } $oObj->DBUpdate(); CMDBSource::Query('COMMIT'); $sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());