From a5b7e06ba24b4efd1c87515d9690d20cda894c8d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 22 Feb 2016 11:01:37 +0100 Subject: [PATCH] Sync: only return modified objects --- library/Director/Import/Sync.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/library/Director/Import/Sync.php b/library/Director/Import/Sync.php index 8796e476..facebf08 100644 --- a/library/Director/Import/Sync.php +++ b/library/Director/Import/Sync.php @@ -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; }