From: Roan Kattouw Date: Thu, 20 Jul 2017 18:38:52 +0000 (-0700) Subject: EnhancedChangesList: Don't render headings for empty days X-Git-Tag: 1.31.0-rc.0~2607^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=11f9d532b450133e233c3250ca11f1ed249b1af9;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 . '
'; } /**