diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 2267c7ea5..92a36f391 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3370,7 +3370,7 @@ EOF $oSet = $this->Get($sAttCode); if (is_null($oSet)) { - $oSet = new ormSet(get_class($this), $sAttCode); + $oSet = new ormSet(get_class($this), $sAttCode, $oAttDef->GetMaxItems()); } $oSet->ApplyDelta($value); $this->Set($sAttCode, $oSet); @@ -3427,7 +3427,14 @@ EOF { $aFinalValues[$sAttCode] = $aValues[$sAttCode]; } - $this->UpdateObjectFromArray($aFinalValues); + try + { + $this->UpdateObjectFromArray($aFinalValues); + } + catch (CoreException $e) + { + $aErrors[] = $e->getMessage(); + } if (!$this->IsNew()) // for new objects this is performed in DBInsertNoReload() { InlineImage::FinalizeInlineImages($this); @@ -3660,8 +3667,14 @@ EOF $aFinalValues[$sAttCode] = $aValues[$sAttCode]; } } - $this->UpdateObjectFromArray($aFinalValues); - + try + { + $this->UpdateObjectFromArray($aFinalValues); + } + catch (CoreException $e) + { + $aErrors[] = $e->getMessage(); + } return $aErrors; } diff --git a/application/wizardhelper.class.inc.php b/application/wizardhelper.class.inc.php index b0fca15d4..a6ec6ff0e 100644 --- a/application/wizardhelper.class.inc.php +++ b/application/wizardhelper.class.inc.php @@ -185,7 +185,7 @@ class WizardHelper else if ($oAttDef instanceof AttributeSet) // AttributeDate is derived from AttributeDateTime { $value = json_decode($value, true); - $oTagSet = new ormSet(get_class($oObj), $sAttCode); + $oTagSet = new ormSet(get_class($oObj), $sAttCode, $oAttDef->GetMaxItems()); $oTagSet->SetValues($value['orig_value']); $oTagSet->ApplyDelta($value); $oObj->Set($sAttCode, $oTagSet); diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 876f1c142..178b4036f 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -1357,7 +1357,7 @@ abstract class DBObject implements iDisplay { if (is_string($toCheck)) { - $oTag = new ormSet(get_class($this), $sAttCode); + $oTag = new ormSet(get_class($this), $sAttCode, $oAtt->GetMaxItems()); try { $aValues = array(); diff --git a/core/ormset.class.inc.php b/core/ormset.class.inc.php index 4578bbdf0..fabc497c4 100644 --- a/core/ormset.class.inc.php +++ b/core/ormset.class.inc.php @@ -195,7 +195,7 @@ class ormSet */ public function GetDelta(ormSet $oOtherSet) { - $oSet = new ormSet($this->sClass, $this->sAttCode); + $oSet = new ormSet($this->sClass, $this->sAttCode, $this->iLimit); // Set the initial value $aOrigItems = $this->GetValues(); $oSet->SetValues($aOrigItems); diff --git a/pages/UI.php b/pages/UI.php index e830473d8..12e420907 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -1071,6 +1071,7 @@ EOF $sClass = utils::ReadPostedParam('class', '', 'class'); $sClassLabel = MetaModel::GetName($sClass); $sTransactionId = utils::ReadPostedParam('transaction_id', ''); + $aErrors = array(); if ( empty($sClass) ) // TO DO: check that the class name is valid ! { throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'class')); @@ -1091,7 +1092,7 @@ EOF $oObj->Set($sStateAttCode, $sTargetState); } } - $oObj->UpdateObjectFromPostedForm(); + $aErrors = $oObj->UpdateObjectFromPostedForm(); } if (isset($oObj) && is_object($oObj)) { @@ -1100,6 +1101,11 @@ EOF try { + if (!empty($aErrors)) + { + throw new CoreCannotSaveObjectException(array('id' => $oObj->GetKey(), 'class' => $sClass, 'issues' => $aErrors)); + } + $oObj->DBInsertNoReload();// No need to reload utils::RemoveTransaction($sTransactionId);