Skip to content

Commit

Permalink
Further fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Oct 31, 2024
1 parent 3f93490 commit 508f62e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Service/DirectoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,23 @@ public function syncExternalDirectory(string $url): array

// Check if we already have this listing
// TODO: This is tricky because it requires a local database call so won't work with open registers
$oldListing = $this->objectService->getObjects(
$oldListings = $this->objectService->getObjects(
objectType: 'listing',
limit: 1,
filters: [
'id'=>$listing['id'],
'directory'=>$listing['directory']
]
);
if ($oldListing !== null && is_array($oldListing) && !empty($oldListing)) {

$oldListing = null;
if (count($oldListings) > 0) {
$oldListing = $oldListings[0];
} else {
unset($listing['id']);
}

if ($oldListing !== null && is_array($oldListing) && empty($oldListing) === false) {
$this->updateListing($listing, $oldListing[0]);
// @todo listing will be added to updatedList even if nothing changed...
$updatedListings[] = $listing['directory'].'/'.$listing['id'];
Expand Down

0 comments on commit 508f62e

Please sign in to comment.