* Fail gracefully on invalid namespace in Special:Newpages
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 27 Oct 2005 22:20:46 +0000 (22:20 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 27 Oct 2005 22:20:46 +0000 (22:20 +0000)
RELEASE-NOTES
includes/SpecialNewpages.php

index 66b6900..3617ead 100644 (file)
@@ -177,6 +177,7 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 3803) Fix links on Special:Wantedcategories with miser mode off
 * Fix Special:BrokenRedirects on MySQL 5.0
 * (bug 3807) Fix 'all' in namespaces drop-down on contribs, rc
+* Fail gracefully on invalid namespace in Special:Newpages
 
 
 === Caveats ===
index 678291b..f718cf5 100644 (file)
@@ -112,6 +112,7 @@ function wfSpecialNewpages($par, $specialPage) {
        global $wgRequest, $wgContLang;
        
        list( $limit, $offset ) = wfCheckLimits();
+       $namespace = NS_MAIN;
        
        if ( $par ) {
                $bits = preg_split( '/\s*,\s*/', trim( $par ) );
@@ -125,14 +126,18 @@ function wfSpecialNewpages($par, $specialPage) {
                                $limit = intval($m[1]);
                        if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) )
                                $offset = intval($m[1]);
-                       if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) )
-                               $namespace = $wgContLang->getNsIndex( $m[1] );
+                       if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
+                               $ns = $wgContLang->getNsIndex( $m[1] );
+                               if( $ns !== false ) {
+                                       $namespace = $ns;
+                               }
+                       }
                }
        }
        if ( ! isset( $shownavigation ) )
                $shownavigation = ! $specialPage->including();
 
-       $npp = new NewPagesPage( isset( $namespace ) ? $namespace : NS_MAIN );
+       $npp = new NewPagesPage( $namespace );
 
        if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ) ) )
                $npp->doQuery( $offset, $limit, $shownavigation );