Fix #13.
This commit is contained in:
parent
3742f4b06c
commit
b7e4374dac
|
@ -39,6 +39,14 @@ class SubscriptionsManager
|
||||||
$oldSubscribersList[] = $subscription->getSubscriber();
|
$oldSubscribersList[] = $subscription->getSubscriber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isFirstTime = false;
|
||||||
|
|
||||||
|
// Preventing to add garbage subscriptions for first processing
|
||||||
|
// @todo improve algorithm
|
||||||
|
if ((count($oldSubscribersList) === 0) && (count($newSubscribersList) > 1)) {
|
||||||
|
$isFirstTime = true;
|
||||||
|
}
|
||||||
|
|
||||||
unset($tmpOldSubscribers);
|
unset($tmpOldSubscribers);
|
||||||
|
|
||||||
$subscribedList = $this->getUsersListsDiff($newSubscribersList, $oldSubscribersList);
|
$subscribedList = $this->getUsersListsDiff($newSubscribersList, $oldSubscribersList);
|
||||||
|
@ -54,17 +62,20 @@ class SubscriptionsManager
|
||||||
|
|
||||||
$user->addSubscriber($subscription);
|
$user->addSubscriber($subscription);
|
||||||
|
|
||||||
$logEvent = new SubscriptionEvent();
|
// If it's not first processing
|
||||||
$logEvent
|
if (!$isFirstTime) {
|
||||||
->setSubscriber($subscribedUser)
|
$logEvent = new SubscriptionEvent();
|
||||||
->setAuthor($user)
|
$logEvent
|
||||||
->setAction(SubscriptionEvent::ACTION_SUBSCRIBE)
|
->setSubscriber($subscribedUser)
|
||||||
;
|
->setAuthor($user)
|
||||||
|
->setAction(SubscriptionEvent::ACTION_SUBSCRIBE);
|
||||||
|
|
||||||
$user->addNewSubscriberEvent($logEvent);
|
$user->addNewSubscriberEvent($logEvent);
|
||||||
|
|
||||||
|
$this->em->persist($logEvent);
|
||||||
|
}
|
||||||
|
|
||||||
$this->em->persist($subscription);
|
$this->em->persist($subscription);
|
||||||
$this->em->persist($logEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($subscribedList);
|
unset($subscribedList);
|
||||||
|
|
Loading…
Reference in a new issue