Skip to content

Commit

Permalink
N°7216 - Import : bug when last field as ExtFieldAttribute is null in…
Browse files Browse the repository at this point in the history
… csv file or missing a comma
  • Loading branch information
accognet committed Sep 27, 2024
1 parent 58c47f4 commit 3f968a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions core/bulkchange.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ protected function IsNullExternalKeySpec($aRowData, $sAttCode)
foreach ($this->m_aExtKeys[$sAttCode] as $sForeignAttCode => $iCol)
{
// The foreign attribute is one of our reconciliation key
if (strlen($aRowData[$iCol]) > 0)
if (isset($aRowData[$iCol]) && strlen($aRowData[$iCol]) > 0)
{
return false;
}
Expand Down Expand Up @@ -1233,11 +1233,19 @@ public function Process(CMDBChange $oChange = null)
$iPreviousTimeLimit = ini_get('max_execution_time');
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');

$iNBFields = count($this->m_aAttList) + count($this->m_aExtKeys);

// Avoid too many events
cmdbAbstractObject::SetEventDBLinksChangedBlocked(true);
try {
foreach ($this->m_aData as $iRow => $aRowData) {
set_time_limit(intval($iLoopTimeLimit));
//stop if not enough cols in $aRowData
if(count($aRowData) != $iNBFields){
$aResult[$iRow]["__STATUS__"] = new RowStatus_Issue('not enough col at line '.$iRow );
continue;
}

if (isset($aResult[$iRow]["__STATUS__"])) {
// An issue at the earlier steps - skip the rest
continue;
Expand Down Expand Up @@ -1348,7 +1356,12 @@ public function Process(CMDBChange $oChange = null)
{
if (!array_key_exists($iCol, $aResult[$iRow]))
{
$aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]);
if(isset($aRowData[$iCol])) {
$aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]);
} else {
//TODO improve message
$aResult[$iRow][$iCol] = new CellStatus_Void('!missing value!');
}
}
}
foreach($this->m_aExtKeys as $sAttCode => $aForeignAtts)
Expand All @@ -1362,7 +1375,12 @@ public function Process(CMDBChange $oChange = null)
if (!array_key_exists($iCol, $aResult[$iRow]))
{
// The foreign attribute is one of our reconciliation key
$aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]);
if(isset($aRowData[$iCol])) {
$aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]);
} else {
//TODO improve message
$aResult[$iRow][$iCol] = new CellStatus_Void('!missing value!');
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pages/ajax.csvimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
$oPanel->AddSubBlock($oTable);

$oPage->AddSubBlock($oPanel);
if (empty($sInitSearchField)) {
if (empty($sInitSearchField) || empty($aInitFieldMapping)) {
// Propose a reconciliation scheme
//
$aReconciliationKeys = MetaModel::GetReconcKeys($sClassName);
Expand Down

0 comments on commit 3f968a0

Please sign in to comment.