Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°7216 import improves error handling missing or null data #612

Open
wants to merge 3 commits into
base: support/3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions core/bulkchange.class.inc.php
Expand Up @@ -458,7 +458,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 @@ -1189,11 +1189,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(Dict::Format('UI:CSVReport-Row-Issue-NbField',count($aRowData),$iNBFields) );
continue;
}

if (isset($aResult[$iRow]["__STATUS__"])) {
// An issue at the earlier steps - skip the rest
continue;
Expand Down Expand Up @@ -1304,7 +1312,11 @@ public function Process(CMDBChange $oChange = null)
{
if (!array_key_exists($iCol, $aResult[$iRow]))
{
$aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol]));
if(isset($aRowData[$iCol])) {
$aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol]));
} else {
$aResult[$iRow][$iCol] = new CellStatus_Issue('', null, Dict::S('UI:CSVReport-Value-Issue-NoValue'));
}
}
}
foreach($this->m_aExtKeys as $sAttCode => $aForeignAtts)
Expand All @@ -1318,7 +1330,11 @@ 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(utils::HtmlEntities($aRowData[$iCol]));
if(isset($aRowData[$iCol])) {
$aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol]));
} else {
$aResult[$iRow][$iCol] = new CellStatus_Issue('', null, 'UI:CSVReport-Value-Issue-NoValue');
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions dictionaries/en.dictionary.itop.ui.php
Expand Up @@ -761,6 +761,8 @@
'UI:CSVReport-Row-Issue-Reconciliation' => 'failed to reconcile',
'UI:CSVReport-Row-Issue-Ambiguous' => 'ambiguous reconciliation',
'UI:CSVReport-Row-Issue-Internal' => 'Internal error: %1$s, %2$s',
'UI:CSVReport-Value-Issue-NoValue' => 'No value',
'UI:CSVReport-Row-Issue-NbField' => 'Not the expected number of fields (current : %1$s fields, expected :%2$s)',

'UI:CSVReport-Icon-Unchanged' => 'Unchanged',
'UI:CSVReport-Icon-Modified' => 'Modified',
Expand Down
2 changes: 2 additions & 0 deletions dictionaries/fr.dictionary.itop.ui.php
Expand Up @@ -732,6 +732,8 @@
'UI:CSVReport-Row-Issue-Reconciliation' => 'Echec de réconciliation',
'UI:CSVReport-Row-Issue-Ambiguous' => 'Réconciliation ambigüe',
'UI:CSVReport-Row-Issue-Internal' => 'Erreur interne: %1$s, %2$s',
'UI:CSVReport-Value-Issue-NoValue' => 'Pas de valeur',
'UI:CSVReport-Row-Issue-NbField' => 'Le nombre de champs ne correspond pas à ce qui est attendu (courant : %1$s champs, %2$s champs attendus )',
'UI:CSVReport-Icon-Unchanged' => 'Non modifié',
'UI:CSVReport-Icon-Modified' => 'Modifié',
'UI:CSVReport-Icon-Missing' => 'A disparu',
Expand Down
2 changes: 1 addition & 1 deletion pages/ajax.csvimport.php
Expand Up @@ -336,7 +336,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