From 97bbd18bdea70e6a5bc9aece6c80b8257b1a5e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Sun, 5 Aug 2018 19:44:58 +0200 Subject: [PATCH] Use accurate count when budling multiple login failure warnings Bug: T194385 Change-Id: I188e08b31b88d99740231554b9239310c57287ab --- includes/PresentationModel.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/PresentationModel.php b/includes/PresentationModel.php index 42f703f..834a156 100644 --- a/includes/PresentationModel.php +++ b/includes/PresentationModel.php @@ -2,6 +2,7 @@ namespace LoginNotify; +use EchoEvent; use EchoEventPresentationModel; use Message; use SpecialPage; @@ -67,7 +68,10 @@ class PresentationModel extends EchoEventPresentationModel { // If it's a bundle, pass it the bundle count as param if ( $this->isBundled() ) { $msg = $this->msg( 'notification-new-bundled-header-login-fail' ); - $msg->params( $this->getBundleCount() ); + $totalAttempts = array_reduce( $this->getBundledEvents(), function ( $sum, EchoEvent $event ) { + return $sum + $event->getExtraParam( 'count', 0 ); + }, 0 ); + $msg->params( $totalAttempts ); } else { // If the bundle is read or user goes to Special:Notifications, show // one notification per attempt (aligned with how unbundled bundles work) @@ -97,4 +101,5 @@ class PresentationModel extends EchoEventPresentationModel { return [ $changePasswordLink ]; } + }