Do not show empty parenthesis on log entry with no block flags
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 31 May 2013 20:18:10 +0000 (22:18 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 31 May 2013 20:18:10 +0000 (22:18 +0200)
When nothing is stored in the database, the explode in
LogPage::formatBlockFlags will explode a empty string to a array with a
empty string as only value. Changed the count(array) check to empty
string check.

Bug: 47035
Change-Id: I879169599a2a24b35e26d4a23ab8202f267d8b00

includes/logging/LogPage.php

index 9d6ab25..521cb8a 100644 (file)
@@ -518,17 +518,17 @@ class LogPage {
         * @return String
         */
        public static function formatBlockFlags( $flags, $lang ) {
-               $flags = explode( ',', trim( $flags ) );
+               $flags = trim( $flags );
+               if ( $flags === '' ) {
+                       return ''; //nothing to do
+               }
+               $flags = explode( ',', $flags );
 
-               if ( count( $flags ) > 0 ) {
-                       for ( $i = 0; $i < count( $flags ); $i++ ) {
-                               $flags[$i] = self::formatBlockFlag( $flags[$i], $lang );
-                       }
-                       return wfMessage( 'parentheses' )->inLanguage( $lang )
-                               ->rawParams( $lang->commaList( $flags ) )->escaped();
-               } else {
-                       return '';
+               for ( $i = 0; $i < count( $flags ); $i++ ) {
+                       $flags[$i] = self::formatBlockFlag( $flags[$i], $lang );
                }
+               return wfMessage( 'parentheses' )->inLanguage( $lang )
+                       ->rawParams( $lang->commaList( $flags ) )->escaped();
        }
 
        /**