|
@@ -1737,7 +1737,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
- $sWarningMessage = count($this->aWarnings)." warnings: ".implode(' '.$this->aWarnings);
|
|
|
|
|
|
+ $sWarningMessage = count($this->aWarnings)." warnings: ".implode(' ', $this->aWarnings);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1845,10 +1845,18 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
$oStatLog->AddTrace("Nothing found on: $sConditionDesc", $this);
|
|
$oStatLog->AddTrace("Nothing found on: $sConditionDesc", $this);
|
|
if ($oDataSource->Get('action_on_zero') == 'create')
|
|
if ($oDataSource->Get('action_on_zero') == 'create')
|
|
{
|
|
{
|
|
- $this->CreateObjectFromReplica($oDataSource->GetTargetClass(), $aAttributes, $oChange, $oStatLog);
|
|
|
|
- if ($this->HasWarnings())
|
|
|
|
|
|
+ $bCreated = $this->CreateObjectFromReplica($oDataSource->GetTargetClass(), $aAttributes, $oChange, $oStatLog);
|
|
|
|
+ if ($bCreated)
|
|
{
|
|
{
|
|
- $oStatLog->Inc('stats_nb_obj_created_warnings');
|
|
|
|
|
|
+ if ($this->HasWarnings())
|
|
|
|
+ {
|
|
|
|
+ $oStatLog->Inc('stats_nb_obj_created_warnings');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // Creation error has precedence over any warning
|
|
|
|
+ $this->ResetWarnings();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else // assumed to be 'error'
|
|
else // assumed to be 'error'
|
|
@@ -1901,10 +1909,18 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
}
|
|
}
|
|
elseif ($oDataSource->Get('action_on_multiple') == 'create')
|
|
elseif ($oDataSource->Get('action_on_multiple') == 'create')
|
|
{
|
|
{
|
|
- $this->CreateObjectFromReplica($oDataSource->GetTargetClass(), $aAttributes, $oChange, $oStatLog);
|
|
|
|
- if ($this->HasWarnings())
|
|
|
|
|
|
+ $bCreated = $this->CreateObjectFromReplica($oDataSource->GetTargetClass(), $aAttributes, $oChange, $oStatLog);
|
|
|
|
+ if ($bCreated)
|
|
{
|
|
{
|
|
- $oStatLog->Inc('stats_nb_obj_created_warnings');
|
|
|
|
|
|
+ if ($this->HasWarnings())
|
|
|
|
+ {
|
|
|
|
+ $oStatLog->Inc('stats_nb_obj_created_warnings');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // Creation error has precedence over any warning
|
|
|
|
+ $this->ResetWarnings();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -2014,9 +2030,11 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates the destination object populating it with the Extended data found in the synchro_data_XXXX table
|
|
* Creates the destination object populating it with the Extended data found in the synchro_data_XXXX table
|
|
|
|
+ * @return bool Whether or not the object was created
|
|
*/
|
|
*/
|
|
protected function CreateObjectFromReplica($sClass, $aAttributes, $oChange, &$oStatLog)
|
|
protected function CreateObjectFromReplica($sClass, $aAttributes, $oChange, &$oStatLog)
|
|
{
|
|
{
|
|
|
|
+ $bCreated = false;
|
|
$oDestObj = MetaModel::NewObject($sClass);
|
|
$oDestObj = MetaModel::NewObject($sClass);
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -2038,6 +2056,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
$this->Set('status_last_error', '');
|
|
$this->Set('status_last_error', '');
|
|
$this->Set('status', 'synchronized');
|
|
$this->Set('status', 'synchronized');
|
|
$this->Set('info_creation_date', date('Y-m-d H:i:s'));
|
|
$this->Set('info_creation_date', date('Y-m-d H:i:s'));
|
|
|
|
+ $bCreated = true;
|
|
|
|
|
|
$oStatLog->AddTrace("Created (".implode(', ', $aValueTrace).")", $this);
|
|
$oStatLog->AddTrace("Created (".implode(', ', $aValueTrace).")", $this);
|
|
$oStatLog->Inc('stats_nb_obj_created');
|
|
$oStatLog->Inc('stats_nb_obj_created');
|
|
@@ -2048,6 +2067,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
$this->SetLastError('Unable to create destination object: ', $e);
|
|
$this->SetLastError('Unable to create destination object: ', $e);
|
|
$oStatLog->Inc('stats_nb_obj_created_errors');
|
|
$oStatLog->Inc('stats_nb_obj_created_errors');
|
|
}
|
|
}
|
|
|
|
+ return $bCreated;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2165,9 +2185,12 @@ class SynchroReplica extends DBObject implements iDisplay
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- // Note: differs from null (in which case the value would be left unchanged)
|
|
|
|
- $oStatLog->AddTrace("Could not find [unique] object for '$sExtAttCode': searched on $sReconcAttCode = '$rawValue'", $this);
|
|
|
|
- $this->AddWarning("Could not find [unique] object for '$sExtAttCode': searched on $sReconcAttCode = '$rawValue'");
|
|
|
|
|
|
+ if ($rawValue != '')
|
|
|
|
+ {
|
|
|
|
+ // Note: differs from null (in which case the value would be left unchanged)
|
|
|
|
+ $oStatLog->AddTrace("Could not find [unique] object for '$sExtAttCode': searched on $sReconcAttCode = '$rawValue'", $this);
|
|
|
|
+ $this->AddWarning("Could not find [unique] object for '$sExtAttCode': searched on $sReconcAttCode = '$rawValue'");
|
|
|
|
+ }
|
|
$retValue = 0;
|
|
$retValue = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|