Merge "Add @coversNothing for left over tests and enable sniff"
[lhc/web/wiklou.git] / includes / specials / SpecialNewpages.php
index ddf52f1..8051b0b 100644 (file)
@@ -76,19 +76,19 @@ class SpecialNewpages extends IncludableSpecialPage {
        protected function parseParams( $par ) {
                $bits = preg_split( '/\s*,\s*/', trim( $par ) );
                foreach ( $bits as $bit ) {
-                       if ( 'shownav' == $bit ) {
+                       if ( $bit === 'shownav' ) {
                                $this->showNavigation = true;
                        }
-                       if ( 'hideliu' === $bit ) {
+                       if ( $bit === 'hideliu' ) {
                                $this->opts->setValue( 'hideliu', true );
                        }
-                       if ( 'hidepatrolled' == $bit ) {
+                       if ( $bit === 'hidepatrolled' ) {
                                $this->opts->setValue( 'hidepatrolled', true );
                        }
-                       if ( 'hidebots' == $bit ) {
+                       if ( $bit === 'hidebots' ) {
                                $this->opts->setValue( 'hidebots', true );
                        }
-                       if ( 'showredirs' == $bit ) {
+                       if ( $bit === 'showredirs' ) {
                                $this->opts->setValue( 'hideredirs', false );
                        }
                        if ( is_numeric( $bit ) ) {
@@ -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 ) {
@@ -222,13 +229,6 @@ class SpecialNewpages extends IncludableSpecialPage {
                $ut = Title::makeTitleSafe( NS_USER, $username );
                $userText = $ut ? $ut->getText() : '';
 
-               // Store query values in hidden fields so that form submission doesn't lose them
-               $hidden = [];
-               foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
-                       $hidden[] = Html::hidden( $key, $value );
-               }
-               $hidden = implode( "\n", $hidden );
-
                $formDescriptor = [
                        'namespace' => [
                                'type' => 'namespaceselect',
@@ -265,6 +265,12 @@ class SpecialNewpages extends IncludableSpecialPage {
                ];
 
                $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
+
+               // Store query values in hidden fields so that form submission doesn't lose them
+               foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
+                       $htmlForm->addHiddenField( $key, $value );
+               }
+
                $htmlForm
                        ->setMethod( 'get' )
                        ->setFormIdentifier( 'newpagesform' )