From: Matthias Schmidt Date: Sat, 9 Aug 2014 08:15:59 +0000 (+0200) Subject: Reduce number of queries for notification access checks X-Git-Tag: 2.1.0_Alpha_1~462^2~4^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e95e11ee583002bde5fca4c3d3777d98383ce644;p=GitHub%2FWoltLab%2FWCF.git Reduce number of queries for notification access checks 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. --- diff --git a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php index d64d1afa4f..4510c05833 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -385,10 +385,6 @@ class UserNotificationHandler extends SingletonFactory { $notification->additionalData ); - if (!$class->checkAccess()) { - continue; - } - if (isset($authorToNotification[$notification->notificationID])) { $eventAuthors = array(); foreach ($authorToNotification[$notification->notificationID] as $userID) { @@ -418,6 +414,13 @@ class UserNotificationHandler extends SingletonFactory { $notifications[] = $data; } + // check access + foreach ($notifications as $index => $notificationData) { + if (!$notificationData['event']->checkAccess()) { + unset($notifications[$index]); + } + } + return array( 'count' => count($notifications), 'notifications' => $notifications