Don't attempt to render block if none of the lines can be shown
authorMatthias Mullie <git@mullie.eu>
Wed, 23 Sep 2015 11:24:34 +0000 (13:24 +0200)
committerMatthias Mullie <git@mullie.eu>
Wed, 23 Sep 2015 11:28:03 +0000 (13:28 +0200)
Not only doesn't it make sense to render this, getLogText has
some assumptions about this array, and an empty array just didn't
work.

Bug: T112738
Change-Id: Ibdc0c4ed15449883a91a3292bfa174ff84116be0

includes/changes/EnhancedChangesList.php

index d912e3a..1dcb7ae 100644 (file)
@@ -283,6 +283,10 @@ class EnhancedChangesList extends ChangesList {
                // Further down are some assumptions that $block is a 0-indexed array
                // with (count-1) as last key. Let's make sure it is.
                $block = array_values( $block );
+               if ( empty( $block ) ) {
+                       // if we can't show anything, don't display this block altogether
+                       return '';
+               }
 
                $r .= $this->getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden );
 
@@ -453,6 +457,10 @@ class EnhancedChangesList extends ChangesList {
         * @return string
         */
        protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
+               if ( empty( $block ) ) {
+                       return '';
+               }
+
                # Changes message
                static $nchanges = array();
                static $sinceLastVisitMsg = array();