mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
🎨 DataSynchro : remove some warnings, code formating
(cherry picked with small modifications from commit 26dcaa0ded : it was reverted on master as this branch contains a fix only version, ok to commit it on develop though)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
/**
|
||||
* Data Exchange web service
|
||||
* Data Exchange web service
|
||||
*
|
||||
* @copyright Copyright (C) 2010-2017 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -28,14 +28,17 @@
|
||||
// - reconciliation is made on the column primary_key
|
||||
//
|
||||
|
||||
if (!defined('__DIR__')) define('__DIR__', dirname(__FILE__));
|
||||
require_once(__DIR__.'/../approot.inc.php');
|
||||
require_once(APPROOT.'/application/application.inc.php');
|
||||
require_once(APPROOT.'/application/webpage.class.inc.php');
|
||||
require_once(APPROOT.'/application/csvpage.class.inc.php');
|
||||
require_once(APPROOT.'/application/clipage.class.inc.php');
|
||||
|
||||
require_once(APPROOT.'/application/startup.inc.php');
|
||||
if (!defined('__DIR__'))
|
||||
{
|
||||
/** @noinspection DirectoryConstantCanBeUsedInspection */
|
||||
define('__DIR__', dirname(__FILE__));
|
||||
}
|
||||
require_once __DIR__.'/../approot.inc.php';
|
||||
require_once APPROOT.'/application/application.inc.php';
|
||||
require_once APPROOT.'/application/webpage.class.inc.php';
|
||||
require_once APPROOT.'/application/csvpage.class.inc.php';
|
||||
require_once APPROOT.'/application/clipage.class.inc.php';
|
||||
require_once APPROOT.'/application/startup.inc.php';
|
||||
|
||||
class ExchangeException extends Exception
|
||||
{
|
||||
@@ -127,15 +130,15 @@ $aPageParams = array
|
||||
'default' => '0',
|
||||
'description' => 'Limit on the count of records that can be loaded at once while performing the synchronization',
|
||||
),
|
||||
/*
|
||||
'reportlevel' => array
|
||||
(
|
||||
'mandatory' => false,
|
||||
'modes' => 'http,cli',
|
||||
'default' => 'errors|warnings|created|changed|unchanged',
|
||||
'description' => 'combination of flags to limit the detailed output',
|
||||
),
|
||||
*/
|
||||
/*
|
||||
'reportlevel' => array
|
||||
(
|
||||
'mandatory' => false,
|
||||
'modes' => 'http,cli',
|
||||
'default' => 'errors|warnings|created|changed|unchanged',
|
||||
'description' => 'combination of flags to limit the detailed output',
|
||||
),
|
||||
*/
|
||||
'simulate' => array
|
||||
(
|
||||
'mandatory' => false,
|
||||
@@ -165,12 +168,12 @@ function UsageAndExit($oP)
|
||||
$bModeCLI = utils::IsModeCLI();
|
||||
|
||||
$oP->p("USAGE:\n");
|
||||
foreach($aPageParams as $sParam => $aParamData)
|
||||
foreach ($aPageParams as $sParam => $aParamData)
|
||||
{
|
||||
$aModes = explode(',', $aParamData['modes']);
|
||||
if ($bModeCLI)
|
||||
{
|
||||
if (in_array('cli', $aModes))
|
||||
if (in_array('cli', $aModes, false))
|
||||
{
|
||||
$sDesc = $aParamData['description'].', '.($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to ['.$aParamData['default'].']');
|
||||
$oP->p("$sParam = $sDesc");
|
||||
@@ -178,7 +181,7 @@ function UsageAndExit($oP)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (in_array('http', $aModes))
|
||||
if (in_array('http', $aModes, false))
|
||||
{
|
||||
$sDesc = $aParamData['description'].', '.($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to ['.$aParamData['default'].']');
|
||||
$oP->p("$sParam = $sDesc");
|
||||
@@ -196,6 +199,7 @@ function ReadParam($oP, $sParam, $sSanitizationFilter = 'parameter')
|
||||
assert(isset($aPageParams[$sParam]));
|
||||
assert(!$aPageParams[$sParam]['mandatory']);
|
||||
$sValue = utils::ReadParam($sParam, $aPageParams[$sParam]['default'], true /* Allow CLI */, $sSanitizationFilter);
|
||||
|
||||
return trim($sValue);
|
||||
}
|
||||
|
||||
@@ -206,17 +210,18 @@ function ReadMandatoryParam($oP, $sParam, $sSanitizationFilter)
|
||||
assert($aPageParams[$sParam]['mandatory']);
|
||||
|
||||
$sValue = utils::ReadParam($sParam, null, true /* Allow CLI */, $sSanitizationFilter);
|
||||
if (is_null($sValue))
|
||||
if ($sValue === null)
|
||||
{
|
||||
$oP->p("ERROR: Missing argument '$sParam'\n");
|
||||
UsageAndExit($oP);
|
||||
}
|
||||
|
||||
return trim($sValue);
|
||||
}
|
||||
|
||||
function ChangeDateFormat($sProposedDate, $sFormat, $bDateOnly)
|
||||
{
|
||||
if ($sProposedDate == '')
|
||||
if ($sProposedDate === '')
|
||||
{
|
||||
// An empty string means 'reset'
|
||||
return '';
|
||||
@@ -226,22 +231,19 @@ function ChangeDateFormat($sProposedDate, $sFormat, $bDateOnly)
|
||||
$sRegExpr = $oFormat->ToRegExpr('/');
|
||||
if (!preg_match($sRegExpr, $sProposedDate))
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
$oDate = $oFormat->Parse($sProposedDate);
|
||||
if ($oDate !== null)
|
||||
{
|
||||
$oDate = $oFormat->Parse($sProposedDate);
|
||||
if ($oDate !== null)
|
||||
{
|
||||
$oTargetFormat = $bDateOnly ? AttributeDate::GetInternalFormat() : AttributeDateTime::GetInternalFormat();
|
||||
$sDate = $oDate->format($oTargetFormat);
|
||||
return $sDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$oTargetFormat = $bDateOnly ? AttributeDate::GetInternalFormat() : AttributeDateTime::GetInternalFormat();
|
||||
$sDate = $oDate->format($oTargetFormat);
|
||||
|
||||
return $sDate;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,18 +260,18 @@ class CLILikeWebPage extends WebPage
|
||||
|
||||
if (utils::IsModeCLI())
|
||||
{
|
||||
$oP = new CLIPage(Dict::S("TitleSynchroExecution"));
|
||||
$oP = new CLIPage(Dict::S('TitleSynchroExecution'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP = new CLILikeWebPage(Dict::S("TitleSynchroExecution"));
|
||||
$oP = new CLILikeWebPage(Dict::S('TitleSynchroExecution'));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
utils::UseParamFile();
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
$oP->p("Error: ".$e->GetMessage());
|
||||
$oP->output();
|
||||
@@ -307,10 +309,10 @@ if (utils::IsModeCLI())
|
||||
else
|
||||
{
|
||||
$_SESSION['login_mode'] = 'basic';
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
require_once APPROOT.'/application/loginwebpage.class.inc.php';
|
||||
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
$sCSVData = utils::ReadPostedParam('csvdata', '', false, 'raw_data');
|
||||
$sCSVData = utils::ReadPostedParam('csvdata', '', 'raw_data');
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +328,7 @@ try
|
||||
$sQualifier = ReadParam($oP, 'qualifier', 'raw_data');
|
||||
$sCharSet = ReadParam($oP, 'charset', 'raw_data');
|
||||
$sDateTimeFormat = ReadParam($oP, 'date_format', 'raw_data');
|
||||
if ($sDateTimeFormat == '')
|
||||
if ($sDateTimeFormat === '')
|
||||
{
|
||||
$sDateTimeFormat = 'Y-m-d H:i:s'; // By default use the SQL date & time format
|
||||
}
|
||||
@@ -342,7 +344,7 @@ try
|
||||
$sComment = ReadParam($oP, 'comment', 'raw_data');
|
||||
$sNoStopOnImportError = ReadParam($oP, 'no_stop_on_import_error');
|
||||
|
||||
if (strtolower(trim($sSep)) == 'tab')
|
||||
if (strtolower(trim($sSep)) === 'tab')
|
||||
{
|
||||
$sSep = "\t";
|
||||
}
|
||||
@@ -351,10 +353,10 @@ try
|
||||
// then exec phase will need this !
|
||||
$oLoadStartDate = SynchroExecution::GetDataBaseCurrentDateTime();
|
||||
|
||||
// Note about date formatting: These MySQL settings are read-only... and in fact unused :-(
|
||||
// Note about date formatting: These MySQL settings are read-only... and in fact unused :-(
|
||||
// SET SESSION date_format = '%d/%m/%Y';
|
||||
// SET SESSION datetime_format = '%d/%m/%Y %H:%i:%s';
|
||||
// Therefore, we have to allow users to transform the format according to a given specification: date_format
|
||||
// SET SESSION datetime_format = '%d/%m/%Y %H:%i:%s';
|
||||
// Therefore, we have to allow users to transform the format according to a given specification: date_format
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
@@ -369,14 +371,14 @@ try
|
||||
//
|
||||
// Check parameters format/consistency
|
||||
//
|
||||
if (strlen($sCSVData) == 0)
|
||||
if (strlen($sCSVData) === 0)
|
||||
{
|
||||
throw new ExchangeException("Missing data - at least one line is expected");
|
||||
throw new ExchangeException('Missing data - at least one line is expected');
|
||||
}
|
||||
|
||||
/** @var \SynchroDataSource $oDataSource */
|
||||
$oDataSource = MetaModel::GetObject('SynchroDataSource', $iDataSourceId, false);
|
||||
if (is_null($oDataSource))
|
||||
if ($oDataSource === null)
|
||||
{
|
||||
throw new ExchangeException("Unknown data source id: '$iDataSourceId'");
|
||||
}
|
||||
@@ -397,18 +399,18 @@ try
|
||||
throw new ExchangeException("Unknown output format: '$sOutput'");
|
||||
}
|
||||
|
||||
/*
|
||||
$aReportLevels = explode('|', $sReportLevel);
|
||||
foreach($aReportLevels as $sLevel)
|
||||
{
|
||||
if (!in_array($sLevel, explode('|', 'errors|warnings|created|changed|unchanged')))
|
||||
/*
|
||||
$aReportLevels = explode('|', $sReportLevel);
|
||||
foreach($aReportLevels as $sLevel)
|
||||
{
|
||||
throw new ExchangeException("Unknown level in reporting level: '$sLevel'");
|
||||
if (!in_array($sLevel, explode('|', 'errors|warnings|created|changed|unchanged')))
|
||||
{
|
||||
throw new ExchangeException("Unknown level in reporting level: '$sLevel'");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
if ($sSimulate == '1')
|
||||
if ($sSimulate === '1')
|
||||
{
|
||||
$bSimulate = true;
|
||||
}
|
||||
@@ -417,7 +419,7 @@ try
|
||||
$bSimulate = false;
|
||||
}
|
||||
|
||||
if ($sSynchronize == '1')
|
||||
if ($sSynchronize === '1')
|
||||
{
|
||||
$bSynchronize = true;
|
||||
}
|
||||
@@ -430,15 +432,15 @@ try
|
||||
//
|
||||
// Parse first line, check attributes, analyse the request
|
||||
//
|
||||
if ($sCharSet == 'UTF-8')
|
||||
if ($sCharSet === 'UTF-8')
|
||||
{
|
||||
$sUTF8Data = $sCSVData;
|
||||
$sUTF8Data = $sCSVData;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sUTF8Data = iconv($sCharSet, 'UTF-8//IGNORE//TRANSLIT', $sCSVData);
|
||||
}
|
||||
$oCSVParser = new CSVParser($sUTF8Data, $sSep, $sQualifier, MetaModel::GetConfig()->Get('max_execution_time_per_loop'));
|
||||
$oCSVParser = new CSVParser($sUTF8Data, $sSep, $sQualifier, MetaModel::GetConfig()->Get('max_execution_time_per_loop'));
|
||||
|
||||
$aInputColumns = $oCSVParser->ListFields();
|
||||
$iColCount = count($aInputColumns);
|
||||
@@ -447,7 +449,7 @@ try
|
||||
$aColumns = $oDataSource->GetSQLColumns();
|
||||
|
||||
$aDateColumns = array();
|
||||
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
||||
foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
||||
{
|
||||
if ($oAttDef instanceof AttributeDate)
|
||||
{
|
||||
@@ -461,7 +463,7 @@ try
|
||||
|
||||
$aIsDateToTransform = array();
|
||||
$aDateToTransformReport = array();
|
||||
foreach($aInputColumns as $iFieldId => $sInputColumn)
|
||||
foreach ($aInputColumns as $iFieldId => $sInputColumn)
|
||||
{
|
||||
if (array_key_exists($sInputColumn, $aDateColumns))
|
||||
{
|
||||
@@ -473,7 +475,7 @@ try
|
||||
$aIsDateToTransform[$iFieldId] = false;
|
||||
}
|
||||
|
||||
if ($sInputColumn == 'primary_key')
|
||||
if ($sInputColumn === 'primary_key')
|
||||
{
|
||||
$iPrimaryKeyCol = $iFieldId;
|
||||
continue;
|
||||
@@ -494,51 +496,51 @@ try
|
||||
//
|
||||
try
|
||||
{
|
||||
if ($sOutput == 'details')
|
||||
if ($sOutput === 'details')
|
||||
{
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
$oP->add_comment(' Import phase');
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
}
|
||||
|
||||
|
||||
if ($bSimulate)
|
||||
{
|
||||
CMDBSource::Query('START TRANSACTION');
|
||||
}
|
||||
$aData = $oCSVParser->ToArray();
|
||||
$iLineCount = count($aData);
|
||||
|
||||
|
||||
$sTable = $oDataSource->GetDataTable();
|
||||
|
||||
// Prepare insert columns
|
||||
|
||||
// Prepare insert columns
|
||||
$sInsertColumns = '`'.implode('`, `', $aInputColumns).'`';
|
||||
|
||||
|
||||
$iPreviousTimeLimit = ini_get('max_execution_time');
|
||||
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
|
||||
$oMutex = new iTopMutex('synchro_import_'.$oDataSource->GetKey());
|
||||
$oMutex->Lock();
|
||||
foreach($aData as $iRow => $aRow)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
$sReconciliationCondition = "`primary_key` = ".CMDBSource::Quote($aRow[$iPrimaryKeyCol]);
|
||||
$sSelect = "SELECT COUNT(*) FROM `$sTable` WHERE $sReconciliationCondition";
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
foreach ($aData as $iRow => $aRow)
|
||||
{
|
||||
$sReconciliationCondition = '`primary_key` = '.CMDBSource::Quote($aRow[$iPrimaryKeyCol]);
|
||||
$sSelect = "SELECT COUNT(*) FROM `$sTable` WHERE $sReconciliationCondition";
|
||||
$aRes = CMDBSource::QueryToArray($sSelect);
|
||||
$iCount = $aRes[0]['COUNT(*)'];
|
||||
|
||||
if ($iCount == 0)
|
||||
$iCount = (int)$aRes[0]['COUNT(*)'];
|
||||
|
||||
if ($iCount === 0)
|
||||
{
|
||||
// No record... create it
|
||||
//
|
||||
$iCountCreations++;
|
||||
if ($sOutput == 'details')
|
||||
if ($sOutput === 'details')
|
||||
{
|
||||
$oP->add("$iRow: New entry, reconciliation: '$sReconciliationCondition'\n");
|
||||
}
|
||||
|
||||
|
||||
$aValues = array(); // Used to build the insert query
|
||||
foreach ($aRow as $iCol => $value)
|
||||
{
|
||||
if (is_null($value))
|
||||
if ($value === null)
|
||||
{
|
||||
$aValues[] = 'NULL';
|
||||
}
|
||||
@@ -546,7 +548,7 @@ try
|
||||
{
|
||||
$bDateOnly = false;
|
||||
$sFormat = $sDateTimeFormat;
|
||||
if ($aIsDateToTransform[$iCol] == 'DATE')
|
||||
if ($aIsDateToTransform[$iCol] === 'DATE')
|
||||
{
|
||||
$bDateOnly = true;
|
||||
$sFormat = $sDateFormat;
|
||||
@@ -555,7 +557,7 @@ try
|
||||
if ($sDate === false)
|
||||
{
|
||||
$aValues[] = CMDBSource::Quote('');
|
||||
if ($sOutput == 'details')
|
||||
if ($sOutput === 'details')
|
||||
{
|
||||
$oP->add("$iRow: Wrong format for {$aIsDateToTransform[$iCol]} column $iCol: '$value' does not match the expected format: '$sFormat' (column skipped)\n");
|
||||
}
|
||||
@@ -576,9 +578,9 @@ try
|
||||
{
|
||||
CMDBSource::Query($sInsert);
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
if ($sNoStopOnImportError == '1')
|
||||
if ($sNoStopOnImportError === '1')
|
||||
{
|
||||
$iCountErrors++;
|
||||
$oP->add("$iRow: Import error '".$e->getMessage()."' (continuing)...\n");
|
||||
@@ -589,28 +591,30 @@ try
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($iCount == 1)
|
||||
elseif ($iCount === 1)
|
||||
{
|
||||
// Found a match... update it
|
||||
//
|
||||
$iCountUpdates++;
|
||||
if ($sOutput == 'details')
|
||||
if ($sOutput === 'details')
|
||||
{
|
||||
$oP->add("$iRow: Update entry, reconciliation: '$sReconciliationCondition'\n");
|
||||
}
|
||||
|
||||
$aValuePairs = array(); // Used to build the update query
|
||||
foreach ($aRow as $iCol => $value)
|
||||
{
|
||||
// Skip reconciliation column
|
||||
if ($iCol == $iPrimaryKeyCol) continue;
|
||||
|
||||
if ($iCol === $iPrimaryKeyCol)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$sCol = $aInputColumns[$iCol];
|
||||
if ($aIsDateToTransform[$iCol] !== false)
|
||||
{
|
||||
$bDateOnly = false;
|
||||
$sFormat = $sDateTimeFormat;
|
||||
if ($aIsDateToTransform[$iCol] == 'DATE')
|
||||
if ($aIsDateToTransform[$iCol] === 'DATE')
|
||||
{
|
||||
$bDateOnly = true;
|
||||
$sFormat = $sDateFormat;
|
||||
@@ -618,7 +622,7 @@ try
|
||||
$sDate = ChangeDateFormat($value, $sFormat, $bDateOnly);
|
||||
if ($sDate === false)
|
||||
{
|
||||
if ($sOutput == 'details')
|
||||
if ($sOutput === 'details')
|
||||
{
|
||||
$oP->add("$iRow: Wrong format for {$aIsDateToTransform[$iCol]} column $iCol: '$value' does not match the expected format: '$sFormat' (column skipped)\n");
|
||||
}
|
||||
@@ -639,9 +643,9 @@ try
|
||||
{
|
||||
CMDBSource::Query($sUpdateQuery);
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
if ($sNoStopOnImportError == '1')
|
||||
if ($sNoStopOnImportError === '1')
|
||||
{
|
||||
$iCountErrors++;
|
||||
$oP->add("$iRow: Import error '".$e->getMessage()."' (continuing)...\n");
|
||||
@@ -662,29 +666,29 @@ try
|
||||
}
|
||||
$oMutex->Unlock();
|
||||
set_time_limit($iPreviousTimeLimit);
|
||||
|
||||
if (($sOutput == "summary") || ($sOutput == 'details'))
|
||||
|
||||
if (($sOutput === 'summary') || ($sOutput === 'details'))
|
||||
{
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
$oP->add_comment(' Import phase summary');
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
$oP->add_comment("Data Source: ".$iDataSourceId);
|
||||
$oP->add_comment("Synchronize: ".($bSynchronize ? '1' : '0'));
|
||||
$oP->add_comment("Class: ".$sClass);
|
||||
$oP->add_comment("Separator: ".$sSep);
|
||||
$oP->add_comment("Qualifier: ".$sQualifier);
|
||||
$oP->add_comment("Charset Encoding:".$sCharSet);
|
||||
$oP->add_comment('Data Source: '.$iDataSourceId);
|
||||
$oP->add_comment('Synchronize: '.($bSynchronize ? '1' : '0'));
|
||||
$oP->add_comment('Class: '.$sClass);
|
||||
$oP->add_comment('Separator: '.$sSep);
|
||||
$oP->add_comment('Qualifier: '.$sQualifier);
|
||||
$oP->add_comment('Charset Encoding:'.$sCharSet);
|
||||
|
||||
if (strlen($sDateTimeFormat) > 0)
|
||||
{
|
||||
$aDateTimeColumns = array();
|
||||
$aDateColumns = array();
|
||||
foreach($aIsDateToTransform as $iCol => $sType)
|
||||
foreach ($aIsDateToTransform as $iCol => $sType)
|
||||
{
|
||||
if ($sType !== false)
|
||||
{
|
||||
$sCol = $aInputColumns[$iCol];
|
||||
if ($sType == 'DATE')
|
||||
if ($sType === 'DATE')
|
||||
{
|
||||
$aDateColumns[] = $sCol;
|
||||
}
|
||||
@@ -694,7 +698,8 @@ try
|
||||
}
|
||||
}
|
||||
}
|
||||
$sFormatedDateTimeColumns = (count($aDateTimeColumns) > 0) ? ', applied to columns ['.implode(', ', $aDateTimeColumns).']' : '';
|
||||
$sFormatedDateTimeColumns = (count($aDateTimeColumns) > 0) ? ', applied to columns ['.implode(', ',
|
||||
$aDateTimeColumns).']' : '';
|
||||
$sFormatedDateColumns = (count($aDateColumns) > 0) ? ', applied to columns ['.implode(', ', $aDateColumns).']' : '';
|
||||
$oP->add_comment("Date and time format: '$sDateTimeFormat' $sFormatedDateTimeColumns");
|
||||
$oP->add_comment("Date only format: '$sDateFormat' $sFormatedDateColumns");
|
||||
@@ -702,19 +707,19 @@ try
|
||||
else
|
||||
{
|
||||
// shall never get there
|
||||
$oP->add_comment("Date format: <none>");
|
||||
$oP->add_comment('Date format: <none>');
|
||||
}
|
||||
$oP->add_comment("Data Size: ".strlen($sCSVData));
|
||||
$oP->add_comment("Data Lines: ".$iLineCount);
|
||||
$oP->add_comment("Columns: ".implode(', ', $aInputColumns));
|
||||
$oP->add_comment("Output format: ".$sOutput);
|
||||
// $oP->add_comment("Report level: ".$sReportLevel);
|
||||
$oP->add_comment("Simulate: ".($bSimulate ? '1' : '0'));
|
||||
$oP->add_comment("Change tracking comment: ".$sComment);
|
||||
$oP->add_comment("Issues (before synchro): ".$iCountErrors);
|
||||
// $oP->add_comment("Warnings: ".$iCountWarnings);
|
||||
$oP->add_comment("Created (before synchro): ".$iCountCreations);
|
||||
$oP->add_comment("Updated (before synchro): ".$iCountUpdates);
|
||||
$oP->add_comment('Data Size: '.strlen($sCSVData));
|
||||
$oP->add_comment('Data Lines: '.$iLineCount);
|
||||
$oP->add_comment('Columns: '.implode(', ', $aInputColumns));
|
||||
$oP->add_comment('Output format: '.$sOutput);
|
||||
// $oP->add_comment("Report level: ".$sReportLevel);
|
||||
$oP->add_comment('Simulate: '.($bSimulate ? '1' : '0'));
|
||||
$oP->add_comment('Change tracking comment: '.$sComment);
|
||||
$oP->add_comment('Issues (before synchro): '.$iCountErrors);
|
||||
// $oP->add_comment("Warnings: ".$iCountWarnings);
|
||||
$oP->add_comment('Created (before synchro): '.$iCountCreations);
|
||||
$oP->add_comment('Updated (before synchro): '.$iCountUpdates);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
@@ -725,7 +730,7 @@ try
|
||||
{
|
||||
$oSynchroExec = new SynchroExecution($oDataSource, $oLoadStartDate);
|
||||
$oStatLog = $oSynchroExec->Process();
|
||||
if ($sOutput == 'details')
|
||||
if ($sOutput === 'details')
|
||||
{
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
$oP->add_comment(' Synchronization phase');
|
||||
@@ -736,35 +741,35 @@ try
|
||||
$iCount++;
|
||||
$oP->add_comment($sMessage);
|
||||
}
|
||||
if ($iCount == 0)
|
||||
if ($iCount === 0)
|
||||
{
|
||||
$oP->add_comment(' No traces. (To activate the traces set "synchro_trace" => true in the configuration file)');
|
||||
}
|
||||
}
|
||||
if ($oStatLog->Get('status') == 'error')
|
||||
if ($oStatLog->Get('status') === 'error')
|
||||
{
|
||||
$oP->p("ERROR: ".$oStatLog->Get('last_error'));
|
||||
$oP->p('ERROR: '.$oStatLog->Get('last_error'));
|
||||
}
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
$oP->add_comment(' Synchronization phase summary');
|
||||
$oP->add_comment('------------------------------------------------------------');
|
||||
$oP->add_comment("Replicas: ".$oStatLog->Get('stats_nb_replica_total'));
|
||||
$oP->add_comment("Replicas touched since last synchro: ".$oStatLog->Get('stats_nb_replica_seen'));
|
||||
$oP->add_comment("Objects deleted: ".$oStatLog->Get('stats_nb_obj_deleted'));
|
||||
$oP->add_comment("Objects deletion errors: ".$oStatLog->Get('stats_nb_obj_deleted_errors'));
|
||||
$oP->add_comment("Objects obsoleted: ".$oStatLog->Get('stats_nb_obj_obsoleted'));
|
||||
$oP->add_comment("Objects obsolescence errors: ".$oStatLog->Get('stats_nb_obj_obsoleted_errors'));
|
||||
$oP->add_comment("Objects created: ".$oStatLog->Get('stats_nb_obj_created')." (".$oStatLog->Get('stats_nb_obj_created_warnings')." warnings)");
|
||||
$oP->add_comment("Objects creation errors: ".$oStatLog->Get('stats_nb_obj_created_errors'));
|
||||
$oP->add_comment("Objects updated: ".$oStatLog->Get('stats_nb_obj_updated')." (".$oStatLog->Get('stats_nb_obj_updated_warnings')." warnings)");
|
||||
$oP->add_comment("Objects update errors: ".$oStatLog->Get('stats_nb_obj_updated_errors'));
|
||||
$oP->add_comment("Objects reconciled (updated): ".$oStatLog->Get('stats_nb_obj_new_updated')." (".$oStatLog->Get('stats_nb_obj_new_updated_warnings')." warnings)");
|
||||
$oP->add_comment("Objects reconciled (unchanged): ".$oStatLog->Get('stats_nb_obj_new_unchanged')." (".$oStatLog->Get('stats_nb_obj_new_updated_warnings')." warnings)");
|
||||
$oP->add_comment("Objects reconciliation errors: ".$oStatLog->Get('stats_nb_replica_reconciled_errors'));
|
||||
$oP->add_comment("Replica disappeared, no action taken: ".$oStatLog->Get('stats_nb_replica_disappeared_no_action'));
|
||||
$oP->add_comment('Replicas: '.$oStatLog->Get('stats_nb_replica_total'));
|
||||
$oP->add_comment('Replicas touched since last synchro: '.$oStatLog->Get('stats_nb_replica_seen'));
|
||||
$oP->add_comment('Objects deleted: '.$oStatLog->Get('stats_nb_obj_deleted'));
|
||||
$oP->add_comment('Objects deletion errors: '.$oStatLog->Get('stats_nb_obj_deleted_errors'));
|
||||
$oP->add_comment('Objects obsoleted: '.$oStatLog->Get('stats_nb_obj_obsoleted'));
|
||||
$oP->add_comment('Objects obsolescence errors: '.$oStatLog->Get('stats_nb_obj_obsoleted_errors'));
|
||||
$oP->add_comment('Objects created: '.$oStatLog->Get('stats_nb_obj_created').' ('.$oStatLog->Get('stats_nb_obj_created_warnings').' warnings)');
|
||||
$oP->add_comment('Objects creation errors: '.$oStatLog->Get('stats_nb_obj_created_errors'));
|
||||
$oP->add_comment('Objects updated: '.$oStatLog->Get('stats_nb_obj_updated').' ('.$oStatLog->Get('stats_nb_obj_updated_warnings')." warnings)");
|
||||
$oP->add_comment('Objects update errors: '.$oStatLog->Get('stats_nb_obj_updated_errors'));
|
||||
$oP->add_comment('Objects reconciled (updated): '.$oStatLog->Get('stats_nb_obj_new_updated').' ('.$oStatLog->Get('stats_nb_obj_new_updated_warnings').' warnings)');
|
||||
$oP->add_comment('Objects reconciled (unchanged): '.$oStatLog->Get('stats_nb_obj_new_unchanged').' ('.$oStatLog->Get('stats_nb_obj_new_updated_warnings').' warnings)');
|
||||
$oP->add_comment('Objects reconciliation errors: '.$oStatLog->Get('stats_nb_replica_reconciled_errors'));
|
||||
$oP->add_comment('Replica disappeared, no action taken: '.$oStatLog->Get('stats_nb_replica_disappeared_no_action'));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
if ($bSimulate)
|
||||
{
|
||||
@@ -781,23 +786,18 @@ try
|
||||
//
|
||||
// Summary of settings and results
|
||||
//
|
||||
if ($sOutput == 'retcode')
|
||||
if ($sOutput === 'retcode')
|
||||
{
|
||||
$oP->add($iCountErrors);
|
||||
}
|
||||
}
|
||||
catch(ExchangeException $e)
|
||||
catch (ExchangeException $e)
|
||||
{
|
||||
$oP->add_comment($e->getMessage());
|
||||
$oP->add_comment($e->getMessage());
|
||||
}
|
||||
catch(SecurityException $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
$oP->add_comment($e->getMessage());
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$oP->add_comment((string)$e);
|
||||
$oP->add_comment((string)$e);
|
||||
}
|
||||
|
||||
$oP->output();
|
||||
?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user