From 11f9d532b450133e233c3250ca11f1ed249b1af9 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 20 Jul 2017 11:38:52 -0700 Subject: [PATCH] EnhancedChangesList: Don't render headings for empty days EnhancedChangesList renders an

for every day, but it does so before it starts rendering the changes for that day. If all of the changes for a different day fail to render (due to permissions issues, extension hooks, or whatever) this would result in an empty heading. Instead, render the heading after formatting is complete, so that if all changes for a given day are dropped, the heading is also dropped. Bug: T171078 Change-Id: I8a0c6cbd679976d18d2c2e6e9ac972fb7b294a42 --- includes/changes/EnhancedChangesList.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 30c6995008..55cb9edd08 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -102,15 +102,17 @@ class EnhancedChangesList extends ChangesList { $rc->mAttribs['rc_timestamp'], $this->getUser() ); + if ( $this->lastdate === '' ) { + $this->lastdate = $date; + } $ret = ''; - # If it's a new day, add the headline and flush the cache - if ( $date != $this->lastdate ) { - # Process current cache + # If it's a new day, flush the cache and update $this->lastdate + if ( $date !== $this->lastdate ) { + # Process current cache (uses $this->lastdate to generate a heading) $ret = $this->recentChangesBlock(); $this->rc_cache = []; - $ret .= Xml::element( 'h4', null, $date ) . "\n"; $this->lastdate = $date; } @@ -763,7 +765,11 @@ class EnhancedChangesList extends ChangesList { } } - return '
' . $blockOut . '
'; + if ( $blockOut === '' ) { + return ''; + } + // $this->lastdate is kept up to date by recentChangesLine() + return Xml::element( 'h4', null, $this->lastdate ) . "\n
" . $blockOut . '
'; } /** -- 2.20.1