N°454 - Check data validity during CSV import

* "simulate" phase is more permissive on new hierarchical entries
* Better check during "apply" phase

SVN:trunk[5000]
This commit is contained in:
Eric Espié
2017-10-11 09:28:23 +00:00
parent d504fb209f
commit 5408545c07
2 changed files with 50 additions and 19 deletions

View File

@@ -1199,24 +1199,16 @@ abstract class DBObject implements iDisplay
}
elseif ($oAtt->IsExternalKey())
{
if (!MetaModel::SkipCheckExtKeys())
// Hierachical keys are always tested because an infinite loop can be created.
if (!MetaModel::SkipCheckExtKeys() || $oAtt->IsHierarchicalKey())
{
$sTargetClass = $oAtt->GetTargetClass();
$oTargetObj = MetaModel::GetObject($sTargetClass, $toCheck, false /*must be found*/, true /*allow all data*/);
if (is_null($oTargetObj))
{
return "Target object not found ($sTargetClass::$toCheck)";
}
// Check allowed values
$aValues = $oAtt->GetAllowedValues($this->ToArgsForQuery());
if (count($aValues) > 0)
if (!array_key_exists($toCheck, $aValues))
{
if (!array_key_exists($toCheck, $aValues))
{
return "Value not allowed [$toCheck]";
}
return "Value not allowed [$toCheck]";
}
}
}
}
elseif ($oAtt->IsScalar())
{