Fix logic for finding the oldest comment in a bundle

Follow-up to Ifba218871122901031a891034e709b886fc406da.

Bug: T302014
Change-Id: If1572a3ff13e922d86c0eca3d252cb196d329ea7
This commit is contained in:
Ed Sanders 2022-03-07 23:13:06 +00:00 committed by Bartosz Dziewoński
parent d478371db3
commit 039d8e21e4

View file

@ -72,10 +72,14 @@ trait DiscussionToolsEventTrait {
// * User talk page notifications are bundled per-page (so basically, always bundled).
// * Mention notifications are *never* bundled.
// Just pass the first comment in the bundle. The client has access to the comment
// Just pass the oldest comment in the bundle. The client has access to the comment
// tree and so can work out all the other comments since this one.
$firstEvent = $this->getBundledEvents()[ 0 ];
$params = [ 'dtnewcommentssince' => $firstEvent->getExtraParam( 'comment-id' ) ];
// This does not include the newest comment, $this->event, but we are looking
// for the oldest comment.
$bundledEvents = $this->getBundledEvents();
$oldestEvent = end( $bundledEvents );
$params = [ 'dtnewcommentssince' => $oldestEvent->getExtraParam( 'comment-id' ) ];
if ( $this->event->getExtraParam( 'subscribed-comment-name' ) ) {
// Topic notifications: Tell client to restrict highlights to this thread
$params[ 'dtinthread' ] = 1;