Skip to content

Commit

Permalink
If multiget fails, fall back to individual GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mstilkerich committed Jul 18, 2020
1 parent 51c13a1 commit df736fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Services/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,18 @@ private function synchronizeOneBatch(
// FETCH THE CHANGED ADDRESS OBJECTS
if (!empty($syncResult->changedObjects)) {
if ($abook->supportsMultiGet()) {
$this->multiGetChanges($client, $abook, $syncResult, $requestedVCardProps);
try {
$this->multiGetChanges($client, $abook, $syncResult, $requestedVCardProps);
} catch (\Exception $e) {
// if the multiget failed, we can still try to get each card individually
Config::$logger->error("addressbook-multiget REPORT produced exception", [ 'exception' => $e ]);
}
}

// try to manually fill all VCards where multiget did not provide VCF data
foreach ($syncResult->changedObjects as &$objref) {
if (!isset($objref["vcf"])) {
Config::$logger->debug("Fetching " . $objref['uri'] . " via GET");
print_r($objref);
[
'etag' => $objref["etag"],
'vcf' => $objref["vcf"],
Expand Down
2 changes: 1 addition & 1 deletion tests/SyncTestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testVerify(): array
);

foreach ($this->expectedDeletedUris as $uri => $seen) {
Assert::assertTrue($seen, "Card reported as deleted: $uri");
Assert::assertTrue($seen, "Deleted card NOT reported as deleted: $uri");
}

foreach ($this->expectedChangedCards as $uri => $attr) {
Expand Down

0 comments on commit df736fa

Please sign in to comment.