Merge "SpecialNewPages: Fix omitted Show/Hide redirect value"
[lhc/web/wiklou.git] / includes / specials / SpecialNewpages.php
index a93b522..33a1990 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 ) {
@@ -229,7 +236,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                }
                $hidden = implode( "\n", $hidden );
 
-               $form = [
+               $formDescriptor = [
                        'namespace' => [
                                'type' => 'namespaceselect',
                                'name' => 'namespace',
@@ -264,25 +271,26 @@ class SpecialNewpages extends IncludableSpecialPage {
                        ],
                ];
 
-               $htmlForm = new HTMLForm( $form, $this->getContext() );
-
-               $htmlForm->setSubmitText( $this->msg( 'newpages-submit' )->text() );
-               // The form should be visible on each request (inclusive requests with submitted forms), so
-               // return always false here.
-               $htmlForm->setSubmitCallback(
-                       function () {
-                               return false;
-                       }
-               );
-               $htmlForm->setMethod( 'get' );
-               $htmlForm->setWrapperLegend( true );
-               $htmlForm->setWrapperLegendMsg( 'newpages' );
-               $htmlForm->addFooterText( Html::rawElement(
-                       'div',
-                       null,
-                       $this->filterLinks()
-               ) );
-               $htmlForm->show();
+               $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
+               $htmlForm
+                       ->setMethod( 'get' )
+                       ->setFormIdentifier( 'newpagesform' )
+                       // The form should be visible on each request (inclusive requests with submitted forms), so
+                       // return always false here.
+                       ->setSubmitCallback(
+                               function () {
+                                       return false;
+                               }
+                       )
+                       ->setSubmitText( $this->msg( 'newpages-submit' )->text() )
+                       ->setWrapperLegend( $this->msg( 'newpages' )->text() )
+                       ->addFooterText( Html::rawElement(
+                               'div',
+                               null,
+                               $this->filterLinks()
+                       ) )
+                       ->show();
+               $out->addModuleStyles( 'mediawiki.special' );
        }
 
        /**
@@ -398,7 +406,10 @@ class SpecialNewpages extends IncludableSpecialPage {
 
                // Let extensions add data
                Hooks::run( 'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] );
-               $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
+               $attribs = array_filter( $attribs,
+                       [ Sanitizer::class, 'isReservedDataAttribute' ],
+                       ARRAY_FILTER_USE_KEY
+               );
 
                if ( count( $classes ) ) {
                        $attribs['class'] = implode( ' ', $classes );