Skip to content

Commit 11f9d53

Browse files
committed
EnhancedChangesList: Don't render headings for empty days
EnhancedChangesList renders an <h4> 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
1 parent 22cb66c commit 11f9d53

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

includes/changes/EnhancedChangesList.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ public function recentChangesLine( &$rc, $watched = false, $linenumber = null )
102102
$rc->mAttribs['rc_timestamp'],
103103
$this->getUser()
104104
);
105+
if ( $this->lastdate === '' ) {
106+
$this->lastdate = $date;
107+
}
105108

106109
$ret = '';
107110

108-
# If it's a new day, add the headline and flush the cache
109-
if ( $date != $this->lastdate ) {
110-
# Process current cache
111+
# If it's a new day, flush the cache and update $this->lastdate
112+
if ( $date !== $this->lastdate ) {
113+
# Process current cache (uses $this->lastdate to generate a heading)
111114
$ret = $this->recentChangesBlock();
112115
$this->rc_cache = [];
113-
$ret .= Xml::element( 'h4', null, $date ) . "\n";
114116
$this->lastdate = $date;
115117
}
116118

@@ -763,7 +765,11 @@ protected function recentChangesBlock() {
763765
}
764766
}
765767

766-
return '<div>' . $blockOut . '</div>';
768+
if ( $blockOut === '' ) {
769+
return '';
770+
}
771+
// $this->lastdate is kept up to date by recentChangesLine()
772+
return Xml::element( 'h4', null, $this->lastdate ) . "\n<div>" . $blockOut . '</div>';
767773
}
768774

769775
/**

0 commit comments

Comments
 (0)