From 636a3940cd0bd8130d87ce77a8b98b06d311926a Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 31 Dec 2018 12:10:07 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01915=20import=20:=20fix=20cannot=20creat?= =?UTF-8?q?e=20object=20with=20value=20for=20field=20that=20is=20readonly?= =?UTF-8?q?=20in=20modification=20Last=20fix=20(523e19528e9bd54a78b18a4efe?= =?UTF-8?q?99caa4f059ae5c)=20was=20not=20a=20correct=20solution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index b9589b982..066e72b3f 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -336,7 +336,6 @@ class BulkChange * @param \DBObject $oTargetObj * @param array $aRowData * @param array $aErrors - * @param bool $bIsNewObject * * @return array * @throws \CoreException @@ -345,7 +344,7 @@ class BulkChange * @throws \MySQLException * @throws \MySQLHasGoneAwayException */ - protected function PrepareObject(&$oTargetObj, $aRowData, &$aErrors, $bIsNewObject = false) + protected function PrepareObject(&$oTargetObj, $aRowData, &$aErrors) { $aResults = array(); $aErrors = array(); @@ -490,7 +489,7 @@ class BulkChange if (!$oAttDef->IsWritable() && in_array($sAttCode, $this->m_aReconcilKeys)){ continue; } $aReasons = array(); - $iFlags = ($bIsNewObject) + $iFlags = ($oTargetObj->IsNew()) ? $oTargetObj->GetInitialStateAttributeFlags($sAttCode, $aReasons) : $oTargetObj->GetAttributeFlags($sAttCode, $aReasons); if ( (($iFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY) && ( $oTargetObj->Get($sAttCode) != $aRowData[$iCol]) ) @@ -700,7 +699,7 @@ class BulkChange } } - $aResult[$iRow] = $this->PrepareObject($oTargetObj, $aRowData, $aErrors, true); + $aResult[$iRow] = $this->PrepareObject($oTargetObj, $aRowData, $aErrors); if (count($aErrors) > 0) { @@ -748,7 +747,7 @@ class BulkChange protected function UpdateObject(&$aResult, $iRow, $oTargetObj, $aRowData, CMDBChange $oChange = null) { - $aResult[$iRow] = $this->PrepareObject($oTargetObj, $aRowData, $aErrors, false); + $aResult[$iRow] = $this->PrepareObject($oTargetObj, $aRowData, $aErrors); // Reporting //