Permalink
Browse files

fix(notifications): only prefetch subscribers for ElggEntities

The subscription service can only prefetch the subscribers for
ElggEntities. It tried for all ElggData objects and this caused PHP
crashed

fixes #9780
  • Loading branch information...
jeabakker committed Sep 23, 2016
1 parent 5ad0f46 commit 65be05c567692694e052ae4711450b7c19f2d571
Showing with 8 additions and 6 deletions.
  1. +8 −6 engine/classes/Elgg/Notifications/SubscriptionsService.php
@@ -61,12 +61,14 @@ public function getSubscriptions(\Elgg\Notifications\Event $event) {
if (!$object) {
return $subscriptions;
}
$prefixLength = strlen(self::RELATIONSHIP_PREFIX);
$records = $this->getSubscriptionRecords($object->getContainerGUID());
foreach ($records as $record) {
$deliveryMethods = explode(',', $record->methods);
$subscriptions[$record->guid] = substr_replace($deliveryMethods, '', 0, $prefixLength);
if ($object instanceof \ElggEntity) {
$prefixLength = strlen(self::RELATIONSHIP_PREFIX);
$records = $this->getSubscriptionRecords($object->getContainerGUID());
foreach ($records as $record) {
$deliveryMethods = explode(',', $record->methods);
$subscriptions[$record->guid] = substr_replace($deliveryMethods, '', 0, $prefixLength);
}
}
$params = array('event' => $event);

0 comments on commit 65be05c

Please sign in to comment.