diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 7a590d58b6..8f38847f52 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -1989,7 +1989,10 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass])) $aOrderSpec = array(); foreach ($aOrderBy as $sFieldAlias => $bAscending) { - MyHelpers::CheckValueInArray('field name in ORDER BY spec', $sFieldAlias, self::GetAttributesList($oFilter->GetFirstJoinedClass())); + if ($sFieldAlias != 'id') + { + MyHelpers::CheckValueInArray('field name in ORDER BY spec', $sFieldAlias, self::GetAttributesList($oFilter->GetFirstJoinedClass())); + } if (!is_bool($bAscending)) { throw new CoreException("Wrong direction in ORDER BY spec, found '$bAscending' and expecting a boolean value"); diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index 86566203f1..cb33885f20 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -2361,7 +2361,15 @@ class SynchroExecution $aArguments['step_count'] = $iStepCount; $iStepCount++; + $this->m_oStatLog->AddTrace("Launching a separate process: step $iStepCount"); + list ($iRes, $aOut) = utils::ExecITopScript('synchro/priv_sync_chunk.php', $aArguments); + + $this->m_oStatLog->AddTrace("The script replied:"); + foreach ($aOut as $sOut) + { + $this->m_oStatLog->AddTrace(">>> $sOut"); + } $sLastRes = strtolower(trim(end($aOut))); $bContinue = ($sLastRes == 'continue'); @@ -2447,8 +2455,9 @@ class SynchroExecution if ($iMaxReplica) { - // Re-build the object set and set a LIMIT - $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToObsolete), array() /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sLimitDate, 'curr_pos' => $iCurrPos)); + // Consider a given subset, starting from replica iCurrPos, limited to the count of iMaxReplica + // The replica have to be ordered by id + $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToObsolete), array('id'=>true) /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sLimitDate, 'curr_pos' => $iCurrPos)); $oSetToProcess->SetLimit($iMaxReplica); } else @@ -2542,8 +2551,9 @@ class SynchroExecution if ($iMaxReplica) { - // Re-build the object set and set a LIMIT - $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToSync), array() /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sLimitDate, 'curr_pos' => $iCurrPos), $this->m_aExtDataSpec); + // Consider a given subset, starting from replica iCurrPos, limited to the count of iMaxReplica + // The replica have to be ordered by id + $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToSync), array('id'=>true) /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sLimitDate, 'curr_pos' => $iCurrPos), $this->m_aExtDataSpec); $oSetToProcess->SetLimit($iMaxReplica); } else @@ -2608,14 +2618,15 @@ class SynchroExecution { $this->m_oStatLog->AddTrace("Deletion date: $sDeletionDate"); } - $sSelectToDelete = "SELECT SynchroReplica WHERE id > :curr_pos AND sync_source_id = :source_id AND status IN ('obsolete') AND status_last_seen < :last_import"; + $sSelectToDelete = "SELECT SynchroReplica WHERE id > :curr_pos AND sync_source_id = :source_id AND status IN ('obsolete') AND status_last_seen < :last_import"; $oSetScope = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToDelete), array() /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sDeletionDate, 'curr_pos' => $iCurrPos)); $iCountScope = $oSetScope->Count(); if ($iMaxReplica) { - // Re-build the object set and set a LIMIT - $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToDelete), array() /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sDeletionDate, 'curr_pos' => $iCurrPos)); + // Consider a given subset, starting from replica iCurrPos, limited to the count of iMaxReplica + // The replica have to be ordered by id + $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToDelete), array('id'=>true) /* order by*/, array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sDeletionDate, 'curr_pos' => $iCurrPos)); $oSetToProcess->SetLimit($iMaxReplica); } else