protected function updateForUser($userId) { $userSettings = $this->getUserSettings($userId); $localUris = $userSettings->getLocalURIs(); $xmlrpc = new XmlRpc($userSettings->getUsername(), $userSettings->getPassword()); $start = (new \DateTime())->sub($userSettings->getSyncPeriodAsInterval()); $end = new \DateTime(); $this->logger->debug("Fetching history from %s to %s for user '%s' for localUris: %s", $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s'), $userId, count($localUris) === 0 ? 'all' : implode($localUris, ', ')); try { $history = $xmlrpc->historyGetByDate($start, $end, count($localUris) === 0 ? null : $localUris); } catch (XmlRpcException $e) { $this->logger->error('An XMLRPC exception occurred: %s', $e->getMessage()); throw $e; } catch (HttpException $e) { $this->loger->error('Remote backend failed with HTTP status code %d', $e->getCode()); throw $e; } $this->logger->debug("Fetched %d entries for user '%s'", count($history), $userId); $count = 0; foreach ($history as $entry) { $count += $this->insert($userId, $entry, $userSettings); } $this->logger->debug("Inserted %d entries for user '%s'", $count, $userId); $userSettings->setLastUpdated(); }