From a970c448452cd9e8eb86511f221837915f2b63df Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Tue, 26 Jul 2016 14:59:13 -0400 Subject: [PATCH] Process bundled notifications when the base is filtered out When the base of a bundle cannot be rendered (canRender() returns false), the bundled items still have to be rendered and potentially marked-as-read as well. If we don't do this, the base is filtered out, marked as read, the counter goes down by 1 and the bundled notifications are ignored. On the next query a new base is selected, filtered out, etc. So if a bundle of 10 notifications cannot be rendered because it's 10 new topics on a deleted flow board, the flyout has to be opened 10 times for the counter to finally be 0. Change-Id: I06962b25e36802ef00278e2bc70d5377b5874695 --- includes/api/ApiEchoNotifications.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiEchoNotifications.php b/includes/api/ApiEchoNotifications.php index aa7525728..12591a4bb 100644 --- a/includes/api/ApiEchoNotifications.php +++ b/includes/api/ApiEchoNotifications.php @@ -267,11 +267,16 @@ class ApiEchoNotifications extends ApiCrossWikiBase { $notifs = $bundler->bundle( $notifs ); } - /** @var EchoNotification $notif */ - foreach ( $notifs as $notif ) { + while ( count( $notifs ) ) { + /** @var EchoNotification $notif */ + $notif = array_shift( $notifs ); $output = EchoDataOutputFormatter::formatOutput( $notif, $format, $user, $this->getLanguage() ); if ( $output !== false ) { $result['list'][] = $output; + } elseif ( $bundle && $notif->getBundledNotifications() ) { + // when the bundle_base gets filtered out, bundled notifications + // have to be re-bundled and formatted + $notifs = array_merge( $bundler->bundle( $notif->getBundledNotifications() ), $notifs ); } }