N°3251 - Null in data synchro (fixes the regression introduced in a1f5d80)

- restore the initial behavior, thanks to hipska through PR#166
- refactor so as to make it clear that no SQL injection is possible (and will never be)
- add PHPUnit tests on the data synchronization => up to 20s to execute
- fix utils::ExeciTopScript to alow its usage within the automated test
This commit is contained in:
rquetiez
2020-09-09 22:41:13 +02:00
parent b5cfd1c61e
commit f5a3bb2baa
4 changed files with 581 additions and 557 deletions

View File

@@ -534,11 +534,7 @@ try
$aValues = array(); // Used to build the insert query
foreach ($aRow as $iCol => $value)
{
if ($value === null) // Source CSV: "<NULL>"
{
$aValues[] = null;
}
elseif ($aIsDateToTransform[$iCol] !== false)
if ($aIsDateToTransform[$iCol] !== false)
{
$bDateOnly = false;
$sFormat = $sDateTimeFormat;
@@ -550,7 +546,7 @@ try
$sDate = ChangeDateFormat($value, $sFormat, $bDateOnly);
if ($sDate === false)
{
$aValues[] = CMDBSource::Quote('');
$aValues[] = '';
if ($sOutput === 'details')
{
$oP->add("$iRow: Wrong format for {$aIsDateToTransform[$iCol]} column $iCol: '$value' does not match the expected format: '$sFormat' (column skipped)\n");
@@ -558,15 +554,15 @@ try
}
else
{
$aValues[] = CMDBSource::Quote($sDate);
$aValues[] = $sDate;
}
}
else
{
$aValues[] = CMDBSource::Quote($value);
$aValues[] = $value;
}
}
$sValues = implode(', ', $aValues);
$sValues = implode(', ', CMDBSource::Quote($aValues));
$sInsert = "INSERT INTO `$sTable` ($sInsertColumns) VALUES ($sValues)";
try
{