This commit is contained in:
Alexey Skobkin 2015-06-02 05:39:09 +03:00
parent 94129f3b5c
commit 5bb8c64c98
2 changed files with 14 additions and 3 deletions

View file

@ -67,12 +67,23 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
try { try {
$serviceSubscribers = $api->getUserSubscribersById($serviceUserId); $serviceSubscribers = $api->getUserSubscribersById($serviceUserId);
} catch (\Exception $e) { } catch (\Exception $e) {
// @todo fallback to the local subscribers list
$output->writeln('Error while getting service subscribers'); $output->writeln('Error while getting service subscribers');
$log->error('Error while getting service subscribers.', ['user_login' => $serviceUser->getLogin(), 'user_id' => $serviceUser->getId(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]); $log->error('Error while getting service subscribers.', ['user_login' => $serviceUser->getLogin(), 'user_id' => $serviceUser->getId(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
$serviceSubscribers = [];
foreach ($serviceUser->getSubscribers() as $subscription) {
$serviceSubscribers[] = $subscription->getSubscriber();
}
$output->writeln('Fallback to local list');
$log->error('Fallback to local list');
if (!count($serviceSubscribers)) {
$log->info('No local subscribers. Finishing.');
return false; return false;
} }
}
if ($output->isVerbose()) { if ($output->isVerbose()) {
$output->writeln('Updating service subscribers'); $output->writeln('Updating service subscribers');

View file

@ -184,7 +184,7 @@ class User
/** /**
* Get subscribers * Get subscribers
* *
* @return ArrayCollection * @return Subscription[]|ArrayCollection
*/ */
public function getSubscribers() public function getSubscribers()
{ {