* (bug 9898) Allow viewing all namespaces in Special:Newpages
authorRob Church <robchurch@users.mediawiki.org>
Tue, 5 Jun 2007 00:50:46 +0000 (00:50 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 5 Jun 2007 00:50:46 +0000 (00:50 +0000)
* Removed some bizarre behaviour in Xml::namespaceSelector() that stopped non-numeric indexes working for the "all namespace" option

RELEASE-NOTES
includes/SpecialNewpages.php
includes/Xml.php

index a4f08c2..3d16fe0 100644 (file)
@@ -54,6 +54,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 7691) Show relevant lines from the deletion log when viewing
   a non-existent article or re-creating a previously-deleted article
 * Added variables 'wgRestrictionEdit' and 'wgRestrictionMove' for JS to header
+* (bug 9898) Allow viewing all namespaces in Special:Newpages
 
 == Bugfixes since 1.10 ==
 
index 48037a7..f329a7d 100644 (file)
@@ -36,12 +36,19 @@ class NewPagesPage extends QueryPage {
                }
        }
 
+       private function makeNamespaceWhere() {
+               return $this->namespace !== 'all'
+                       ? ' AND rc_namespace = ' . intval( $this->namespace )
+                       : '';
+       }
+
        function getSQL() {
                global $wgUser, $wgUseRCPatrol;
                $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
                $dbr = wfGetDB( DB_SLAVE );
                list( $recentchanges, $page ) = $dbr->tableNamesN( 'recentchanges', 'page' );
 
+               $nsfilter = $this->makeNamespaceWhere();
                $uwhere = $this->makeUserWhere( $dbr );
 
                # FIXME: text will break with compression
@@ -62,7 +69,8 @@ class NewPagesPage extends QueryPage {
                                page_latest as rev_id
                        FROM $recentchanges,$page
                        WHERE rc_cur_id=page_id AND rc_new=1
-                       AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0
+                       {$nsfilter}
+                       AND page_is_redirect = 0
                        {$uwhere}";
        }
        
@@ -134,7 +142,7 @@ class NewPagesPage extends QueryPage {
                $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
                # Namespace selector
                $form .= '<table><tr><td align="right">' . Xml::label( wfMsg( 'namespace' ), 'namespace' ) . '</td>';
-               $form .= '<td>' . Xml::namespaceSelector( $this->namespace ) . '</td></tr>';
+               $form .= '<td>' . Xml::namespaceSelector( $this->namespace, 'all' ) . '</td></tr>';
                # Username filter
                $form .= '<tr><td align="right">' . Xml::label( wfMsg( 'newpages-username' ), 'mw-np-username' ) . '</td>';
                $form .= '<td>' . Xml::input( 'username', 30, $this->username, array( 'id' => 'mw-np-username' ) ) . '</td></tr>';
@@ -186,7 +194,7 @@ function wfSpecialNewpages($par, $specialPage) {
                        }
                }
        } else {
-               if( $ns = $wgRequest->getInt( 'namespace', 0 ) )
+               if( $ns = $wgRequest->getText( 'namespace', NS_MAIN ) )
                        $namespace = $ns;
                if( $un = $wgRequest->getText( 'username' ) )
                        $username = $un;
index 146232a..b7a035a 100644 (file)
@@ -100,15 +100,8 @@ class Xml {
         */
        public static function namespaceSelector($selected = '', $allnamespaces = null, $includehidden=false) {
                global $wgContLang;
-               if( $selected !== '' ) {
-                       if( is_null( $selected ) ) {
-                               // No namespace selected; let exact match work without hitting Main
-                               $selected = '';
-                       } else {
-                               // Let input be numeric strings without breaking the empty match.
-                               $selected = intval( $selected );
-                       }
-               }
+               if( is_null( $selected ) )
+                       $selected = '';
                $s = "\n<select id='namespace' name='namespace' class='namespaceselector'>\n";
                $arr = $wgContLang->getFormattedNamespaces();
                if( !is_null($allnamespaces) ) {