SpecialRecentchanges: Don't use nonexistent messages for filter selector
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 28 Feb 2014 18:29:11 +0000 (19:29 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 28 Feb 2014 18:31:39 +0000 (19:31 +0100)
Extensions can defined additional filters, but don't need to define
the corresponding messages. If they don't exist, just fall back to
'show' and 'hide'.

This also fixes the double-escaping of selector link contents and adds
missing entries to the list of messages used here.

Follow-up to Ibbfc3cd0.

Bug: 58449
Change-Id: Id323e3b7daced1e7b6b1e1add4e9e1bf7df05e4e

includes/specials/SpecialRecentchanges.php

index ed29019..f5a5206 100644 (file)
@@ -722,12 +722,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        'hidemyself' => 'rcshowhidemine'
                  );
 
-               // The following messages are also used as the link text itself:
-               // rcshowhideminor-show, rcshowhideminor-hide,
-               // rcshowhidebots-show, rcshowhideminor-hide,
-               // rcshowhideanons-show, rcshowhideanons-hide,
-               // rcshowhidepatr-show, rcshowhidepatr-hide,
-               // rcshowhidemine-show, rcshowhidemine-hide.
                $showhide = array( 'show', 'hide' );
 
                foreach ( $this->getCustomFilters() as $key => $params ) {
@@ -740,7 +734,18 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $links = array();
                foreach ( $filters as $key => $msg ) {
-                       $link = $this->makeOptionsLink( $this->msg( $msg . '-' . $showhide[1 - $options[$key]] ),
+                       // The following messages are used here:
+                       // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
+                       // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
+                       // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide.
+                       $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
+                       // Extensions can define additional filters, but don't need to define the corresponding
+                       // messages. If they don't exist, just fall back to 'show' and 'hide'.
+                       if ( !$linkMessage->exists() ) {
+                               $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
+                       }
+
+                       $link = $this->makeOptionsLink( $linkMessage->text(),
                                array( $key => 1 - $options[$key] ), $nondefaults );
                        $links[] = $this->msg( $msg )->rawParams( $link )->escaped();
                }