LoadSubscribersData bug fix.

This commit is contained in:
Alexey Skobkin 2016-12-12 20:07:03 +03:00
parent 84be9d5df4
commit 77b6e866de

View file

@ -33,7 +33,6 @@ class LoadSubscribersData extends AbstractFixture implements OrderedFixtureInter
$minimum = mt_rand(0, count($users)); $minimum = mt_rand(0, count($users));
} }
if ($minimum) {
foreach ($this->getRandomSubscribers($users, $minimum) as $subscriber) { foreach ($this->getRandomSubscribers($users, $minimum) as $subscriber) {
$subscription = new Subscription($user, $subscriber); $subscription = new Subscription($user, $subscriber);
$subscriptionEvent = new SubscriptionEvent($user, $subscriber, SubscriptionEvent::ACTION_SUBSCRIBE); $subscriptionEvent = new SubscriptionEvent($user, $subscriber, SubscriptionEvent::ACTION_SUBSCRIBE);
@ -42,7 +41,6 @@ class LoadSubscribersData extends AbstractFixture implements OrderedFixtureInter
$user->addSubscriber($subscription); $user->addSubscriber($subscription);
} }
} }
}
$om->flush(); $om->flush();
} }
@ -68,6 +66,11 @@ class LoadSubscribersData extends AbstractFixture implements OrderedFixtureInter
$keys = array_rand($users, $number); $keys = array_rand($users, $number);
// If array_rand was called with $number = 1
if (!is_array($keys)) {
$keys = [$keys];
}
$result = []; $result = [];
foreach ($keys as $key) { foreach ($keys as $key) {