If the access check relies on data that needs to be fetched from the database, `AbstractSharedUserNotificationEvent::prepare()` has only be called for the current object, not all objects which causes queries for each object separately instead of one query for all objects.
$notification->additionalData
);
- if (!$class->checkAccess()) {
- continue;
- }
-
if (isset($authorToNotification[$notification->notificationID])) {
$eventAuthors = array();
foreach ($authorToNotification[$notification->notificationID] as $userID) {
$notifications[] = $data;
}
+ // check access
+ foreach ($notifications as $index => $notificationData) {
+ if (!$notificationData['event']->checkAccess()) {
+ unset($notifications[$index]);
+ }
+ }
+
return array(
'count' => count($notifications),
'notifications' => $notifications