SpecialNewPages: Fix omitted Show/Hide redirect value
authorFlorian Schmidt <florian.schmidt.stargatewissen@gmail.com>
Thu, 2 Mar 2017 17:34:03 +0000 (18:34 +0100)
committerFlorianschmidtwelzow <florian.schmidt.stargatewissen@gmail.com>
Mon, 14 Aug 2017 17:35:01 +0000 (17:35 +0000)
The URL parameters will internally parsed to true/false by FormOptions for
the SpecialNewPages class. However, FormOptions::getChangedValues() will also
return an array with values of type boolean. wfArrayToCgi() on the other hand,
according to the doc, does not output null and false values if an array is
passed to it (which is done through the LinkRenderer/Title).

This can be fixed by translating the values from a boolean true false to a true
false parsed as URL values (1 and 0). I did this in the SpecialNewPages itself,
as I'm pretty sure, that this does not belong to the FormOptions::getChangedValues()
function and not to the wfArrayToCgi() function (which would change a very basic
and documented functioning from a widely used method).

Bug: T158504
Change-Id: I6660373b002bdb3a03edaf3b64557ffac8f25c6c

includes/specials/SpecialNewpages.php

index e2c9eab..e378bcf 100644 (file)
@@ -189,6 +189,13 @@ class SpecialNewpages extends IncludableSpecialPage {
                $changed = $this->opts->getChangedValues();
                unset( $changed['offset'] ); // Reset offset if query type changes
 
+               // wfArrayToCgi(), called from LinkRenderer/Title, will not output null and false values
+               // to the URL, which would omit some options (T158504). Fix it by explicitly setting them
+               // to 0 or 1.
+               $changed = array_map( function ( $value ) {
+                       return $value ? '1' : '0';
+               }, $changed );
+
                $self = $this->getPageTitle();
                $linkRenderer = $this->getLinkRenderer();
                foreach ( $filters as $key => $msg ) {