* Remove some hardcoded 0 instead of NS_MAIN
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 11 Jan 2005 18:18:16 +0000 (18:18 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 11 Jan 2005 18:18:16 +0000 (18:18 +0000)
* Note in define.php that people should NOT change the integer values for NS_* constants

16 files changed:
includes/Article.php
includes/Database.php
includes/Defines.php
includes/Linker.php
includes/Skin.php
includes/SpecialAllpages.php
includes/SpecialAncientpages.php
includes/SpecialBrokenRedirects.php
includes/SpecialLonelypages.php
includes/SpecialMaintenance.php
includes/SpecialNewpages.php
includes/SpecialPopularpages.php
includes/SpecialRandompage.php
includes/SpecialShortpages.php
includes/SpecialValidate.php
includes/Title.php

index 6099e3d..56055cc 100644 (file)
@@ -2231,7 +2231,7 @@ function wfArticleIsStub( $articleID ) {
                        array( 'LENGTH(old_text) AS len', 'page_namespace', 'page_is_redirect' ),
                        array( 'page_id' => $articleID, "page.page_latest=text.old_id" ),
                        $fname ) ;
-               if ( $s == false OR $s->page_is_redirect OR $s->page_namespace != 0 ) {
+               if ( $s == false OR $s->page_is_redirect OR $s->page_namespace != NS_MAIN ) {
                        return false;
                }
                $size = $s->len;
index 68dad73..0deaf93 100644 (file)
@@ -652,8 +652,9 @@ class Database {
         * $conds: a condition map, terms are ANDed together. 
         *   Items with numeric keys are taken to be literal conditions
         * Takes an array of selected variables, and a condition map, which is ANDed
-        * e.g. selectRow( "page", array( "page_id" ), array( "page_namespace" => 0, "page_title" => "Astronomy" ) )
-        *   would return an object where $obj->page_id is the ID of the Astronomy article
+        * e.g: selectRow( "page", array( "page_id" ), array( "page_namespace" =>
+        * NS_MAIN, "page_title" => "Astronomy" ) )   would return an object where
+        * $obj- >page_id is the ID of the Astronomy article
         *
         * @todo migrate documentation to phpdocumentor format
         */
index f5b7e9f..c52b2de 100644 (file)
@@ -26,6 +26,8 @@ define('NS_SPECIAL', -1);
  *
  * Number 100 and beyond are reserved for custom namespaces;
  * DO NOT assign standard namespaces at 100 or beyond.
+ * DO NOT Change integer values as they are most probably hardcoded everywhere
+ * see bug #696 which talked about that.
  */
 define('NS_MAIN', 0);
 define('NS_TALK', 1);
index 72770ab..b671a04 100644 (file)
@@ -223,7 +223,7 @@ class Linker {
                                                'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
                                        if ( $s !== false ) {
                                                $size = $s->x;
-                                               if ( $s->cur_is_redirect OR $s->cur_namespace != 0 ) {
+                                               if ( $s->cur_is_redirect OR $s->cur_namespace != NS_MAIN ) {
                                                        $size = $threshold*2 ; # Really big
                                                }
                                        } else {
index 30d013b..14bb190 100644 (file)
@@ -1092,7 +1092,7 @@ class Skin extends Linker {
                if ( 0 == count( $a ) ) {
                        if ( !$wgUseNewInterlanguage ) return '';
                        $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
-                       if ( $ns != 0 AND $ns != 1 ) return '' ;
+                       if ( $ns != NS_MAIN AND $ns != NS_TALK ) return '' ;
                        $pn = 'Intl' ;
                        $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
                        return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
@@ -1266,7 +1266,7 @@ class Skin extends Linker {
        }
 
        # this can be passed the NS number as defined in Language.php
-       /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
+       /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN ) {
                $title = Title::makeTitleSafe( $namespace, $name );
                $this->checkTitle($title, $name);
                return $title->getLocalURL( $urlaction );
index e657842..e21392a 100644 (file)
@@ -30,7 +30,7 @@ function wfSpecialAllpages( $par=NULL ) {
        }
 }
 
-function namespaceForm ( $namespace = 0, $from = '' ) {
+function namespaceForm ( $namespace = NS_MAIN, $from = '' ) {
        global $wgContLang, $wgScript;
 
        $t = Title::makeTitle( NS_SPECIAL, "Allpages" );
@@ -57,7 +57,7 @@ function namespaceForm ( $namespace = 0, $from = '' ) {
        return $out;
 }
 
-function indexShowToplevel ( $namespace = 0 ) {
+function indexShowToplevel ( $namespace = NS_MAIN ) {
        global $wgOut, $indexMaxperpage, $toplevelMaxperpage, $wgContLang, $wgRequest, $wgUser;
        $sk = $wgUser->getSkin();
        $fname = "indexShowToplevel";
@@ -158,7 +158,7 @@ function indexShowToplevel ( $namespace = 0 ) {
        $wgOut->addHtml( $out2 . $out );
 }
 
-function indexShowline( $inpoint, $outpoint, $namespace = 0 ) {
+function indexShowline( $inpoint, $outpoint, $namespace = NS_MAIN ) {
        global $wgOut, $wgLang, $wgUser;
        $sk = $wgUser->getSkin();
        $dbr =& wfGetDB( DB_SLAVE );
@@ -177,7 +177,7 @@ function indexShowline( $inpoint, $outpoint, $namespace = 0 ) {
        return '<tr><td align="right">'.$out.'</td></tr>';
 }
 
-function indexShowChunk( $from, $namespace = 0 ) {
+function indexShowChunk( $from, $namespace = NS_MAIN ) {
        global $wgOut, $wgUser, $indexMaxperpage, $wgContLang;
        $sk = $wgUser->getSkin();
        $maxPlusOne = $indexMaxperpage + 1;
index c847e1e..253c917 100644 (file)
@@ -38,7 +38,7 @@ class AncientPagesPage extends QueryPage {
                                page_title as title,
                                rev_timestamp as value
                        FROM $page, $revision
-                       WHERE page_namespace=0 AND page_is_redirect=0
+                       WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0
                          AND page_latest=rev_id";
        }
        
index 9c48cb4..743e450 100644 (file)
@@ -34,7 +34,7 @@ class BrokenRedirectsPage extends PageQueryPage {
                extract( $dbr->tableNames( 'page', 'brokenlinks' ) );
 
                $sql = "SELECT bl_to,page_title FROM $brokenlinks,$page " .
-                      "WHERE page_is_redirect=1 AND page_namespace=0 AND bl_from=page_id ";
+                      'WHERE page_is_redirect=1 AND page_namespace='.NS_MAIN.' AND bl_from=page_id ';
                return $sql;
        }
 
index 86e0b8d..6f0f73f 100644 (file)
@@ -36,7 +36,7 @@ class LonelyPagesPage extends PageQueryPage {
 
                return "SELECT 'Lonelypages' as type, page_namespace AS namespace, page_title AS title, page_title AS value " .
                        "FROM $page LEFT JOIN $links ON page_id=l_to ".
-                       "WHERE l_to IS NULL AND page_namespace=0 AND page_is_redirect=0";
+                       'WHERE l_to IS NULL AND page_namespace='.NS_MAIN.' AND page_is_redirect=0';
        }
 }
 
index abd88a1..265b706 100644 (file)
@@ -218,7 +218,7 @@ function wfSpecialMispeelings () {
                        $y = $x ;
                        $x = preg_replace( '/^(\S+).*$/', '$1', $x );
                        $sql = "SELECT DISTINCT cur_title FROM $cur,$searchindex WHERE cur_id=si_page AND ".
-                               "cur_namespace=0 AND cur_is_redirect=0 AND " .
+                               "cur_namespace=".NS_MAIN." AND cur_is_redirect=0 AND " .
                                "(MATCH(si_text) AGAINST ('" . $dbr->strencode( $wgContLang->stripForSearch( $x ) ) . "'))" ;
                        $res = $dbr->query( $sql, $fname );
                        while ( $obj = $dbr->fetchObject ( $res ) ) {
@@ -268,7 +268,7 @@ function wfSpecialMissingLanguageLinks() {
        $cur = $dbr->tableName( 'cur' );
 
        $sql = "SELECT cur_title FROM $cur " .
-         "WHERE cur_namespace=0 AND cur_is_redirect=0 " .
+         "WHERE cur_namespace=".NS_MAIN." AND cur_is_redirect=0 " .
          "AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[" . wfStrencode( $thelang ) . ":%' " .
          "LIMIT {$offset}, {$limit}";
 
index 9367a5e..a8935ec 100644 (file)
@@ -51,7 +51,7 @@ class NewPagesPage extends QueryPage {
                                old_text as text
                        FROM $recentchanges,$page,$text
                        WHERE rc_cur_id=page_id AND rc_new=1
-                         AND rc_namespace=0 AND page_is_redirect=0
+                         AND rc_namespace=".NS_MAIN." AND page_is_redirect=0
                          AND page_latest=old_id";
        }
 
index 3234996..4e1a088 100644 (file)
@@ -37,7 +37,7 @@ class PopularPagesPage extends QueryPage {
                                page_title as title,
                                page_counter as value
                        FROM $page
-                       WHERE page_namespace=0 AND page_is_redirect=0";
+                       WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
        }
 
        function formatResult( $skin, $result ) {
index 9a9326c..7cd7ff0 100644 (file)
@@ -34,7 +34,7 @@ function wfSpecialRandompage() {
        }
        $sqlget = "SELECT page_id,page_title
                FROM $page $use_index
-               WHERE page_namespace=0 AND page_is_redirect=0 $extra
+               WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0 $extra
                AND page_random>$randstr
                ORDER BY page_random
                LIMIT 1";
index 1467a44..f996428 100644 (file)
@@ -42,7 +42,7 @@ class ShortPagesPage extends QueryPage {
                                page_title as title,
                                LENGTH(old_text) AS value
                        FROM $page, $text
-                       WHERE page_namespace=0 AND page_is_redirect=0
+                       WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0
                          AND page_latest=old_id";
        }
        
index aaaac55..b1b16f7 100644 (file)
@@ -33,7 +33,7 @@ class Validation {
        function find_this_version( $article_title , &$article_time , &$id , &$tab ) {
                $id = "";
                $tab = "";
-               $sql = "SELECT cur_id,cur_timestamp FROM cur WHERE cur_namespace=0 AND cur_title='" . wfStrencode( $article_title ) . "'";
+               $sql = "SELECT cur_id,cur_timestamp FROM cur WHERE cur_namespace=".NS_MAIN." AND cur_title='" . wfStrencode( $article_title ) . "'";
                $res = wfQuery( $sql, DB_READ );
                if( $s = wfFetchObject( $res ) ) {
                        if ( $article_time == "" ) {
@@ -47,7 +47,7 @@ class Validation {
                }
                        
                if ( $id == "" ) {
-                       $sql = "SELECT old_id FROM old WHERE old_namespace=0 AND old_title='" . wfStrencode( $article_title ) .
+                       $sql = "SELECT old_id FROM old WHERE old_namespace=".NS_MAIN." AND old_title='" . wfStrencode( $article_title ) .
                                "' AND old_timestamp='" . wfStrencode( $article_time ) . "'";
                        $res = wfQuery( $sql, DB_READ );
                        if( $s = wfFetchObject( $res ) ) {
@@ -103,7 +103,7 @@ class Validation {
                if( !isset( $val[$article_time] ) ) {
                        if( $article_time == "" ) {
                                $res = wfQuery( "select cur_timestamp FROM cur WHERE cur_title='" .
-                                       wfStrencode( $article_title ) . "' AND cur_namespace=0", DB_READ );
+                                       wfStrencode( $article_title ) . "' AND cur_namespace=".NS_MAIN, DB_READ );
                                if( $s = wfFetchObject( $res ) ) {
                                        $article_time = $s->cur_timestamp;
                                }
index e9d723d..462afbb 100644 (file)
@@ -55,7 +55,9 @@ class Title {
                $this->mNamespace = 0;
                $this->mRestrictionsLoaded = false;
                $this->mRestrictions = array();
-               $this->mDefaultNamespace = 0;
+               # Dont change the following, NS_MAIN is hardcoded in several place
+               # See bug #696
+               $this->mDefaultNamespace = NS_MAIN;
        }
 
        /**