/** * @param array $revDiff * @return array|void * @throws HTTPException */ public function replicateChanges(&$revDiff) { $allResponse = array('multipartResponse' => array(), 'bulkResponse' => array()); foreach ($revDiff as $docId => $revMisses) { $bulkUpdater = $this->target->createBulkUpdater(); $bulkUpdater->setNewEdits(false); try { list($docStack, $multipartResponse) = $this->source->transferChangedDocuments($docId, $revMisses['missing'], $this->target); } catch (\Exception $e) { // Deal with the failures. Try again once to deal with the // connection establishment failures of the client. // It's better to deal this in the client itself. usleep(500); list($docStack, $multipartResponse) = $this->source->transferChangedDocuments($docId, $revMisses['missing'], $this->target); } $bulkUpdater->updateDocuments($docStack); // $multipartResponse is an empty array in case there was no // transferred revision that had attachment in the current doc. $allResponse['multipartResponse'][$docId] = $multipartResponse; $allResponse['bulkResponse'][$docId] = $bulkUpdater->execute()->status; } return $allResponse; }