* Note in define.php that people should NOT change the integer values for NS_* constants
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;
* $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
*/
*
* 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);
'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 {
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 ),
}
# 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 );
}
}
-function namespaceForm ( $namespace = 0, $from = '' ) {
+function namespaceForm ( $namespace = NS_MAIN, $from = '' ) {
global $wgContLang, $wgScript;
$t = Title::makeTitle( NS_SPECIAL, "Allpages" );
return $out;
}
-function indexShowToplevel ( $namespace = 0 ) {
+function indexShowToplevel ( $namespace = NS_MAIN ) {
global $wgOut, $indexMaxperpage, $toplevelMaxperpage, $wgContLang, $wgRequest, $wgUser;
$sk = $wgUser->getSkin();
$fname = "indexShowToplevel";
$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 );
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;
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";
}
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;
}
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';
}
}
$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 ) ) {
$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}";
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";
}
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 ) {
}
$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";
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";
}
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 == "" ) {
}
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 ) ) {
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;
}
$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;
}
/**