Sync: only return modified objects

This commit is contained in:
Thomas Gelf 2016-02-22 11:01:37 +01:00
parent 13a748a287
commit a5b7e06ba2
1 changed files with 15 additions and 6 deletions

View File

@ -415,18 +415,27 @@ class Sync
}
$objectKey = $rule->object_type === 'datalistEntry' ? 'entry_name' : 'object_name';
$noAction = array();
foreach ($objects as $key => $object) {
if ($object->hasBeenLoadedFromDb() && $rule->purge_existing === 'y') {
if (! array_key_exists($key, $newObjects)) {
$object->markForRemoval();
if (array_key_exists($key, $newObjects)) {
// Stats?
// TODO: this is for stats, preview, summary:
// $this->remove[] = $object;
}
} elseif ($object->hasBeenLoadedFromDb() && $rule->purge_existing === 'y') {
$object->markForRemoval();
// TODO: this is for stats, preview, summary:
// $this->remove[] = $object;
} else {
$noAction[] = $key;
}
}
foreach ($noAction as $key) {
unset($objects[$key]);
}
return $objects;
}