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
This commit is contained in:
Stephane Bisson 2016-07-26 14:59:13 -04:00
parent fa67fc9ea7
commit a970c44845

View file

@ -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 );
}
}