Page MenuHomePhabricator

Several files refer to namespaces by number instead of NS_MAIN, etc.
Closed, DeclinedPublic

Description

Author: qleah

Description:
Most of these assume the main namespace will always be 0.

Skin.php:1259: if ( $ns != 0 AND $ns != 1 ) return '' ;
SpecialAllpages.php:115: $sql = "SELECT cur_title FROM cur WHERE cur_namespace=0
AND cur_title >= '"
SpecialAncientpages.php:24: WHERE cur_namespace=0 AND cur_is_redirect=0";
SpecialBooksources.php:46: "WHERE cur_namespace=4 and cur_title='" .
SpecialLonelypages.php:22: "WHERE l_to IS NULL AND cur_namespace=0 AND
cur_is_redirect=0";
SpecialLongpages.php:22: WHERE cur_namespace=0 AND cur_is_redirect=0";
SpecialMaintenance.php:215: "WHERE cur_is_redirect=1 AND cur_namespace=0 AND
bl_from=cur_id " .
SpecialMaintenance.php:311: #$sql = "SELECT DISTINCT cur_title FROM cur WHERE
cur_namespace=0 AND cur_is_redirect=0 AND (MATCH(cur_ind_text) AGAINST ('" .
wfStrencode( $wgLang->stripForSearch( $x ) ) . "'))" ;
SpecialMaintenance.php:312: $sql = "SELECT DISTINCT cur_title FROM
cur,searchindex WHERE cur_id=si_page AND cur_namespace=0 AND cur_is_redirect=0
AND (MATCH(si_text) AGAINST ('" . wfStrencode( $wgLang->stripForSearch( $x ) ) .
"'))" ;
SpecialMaintenance.php:358: "WHERE cur_namespace=0 AND cur_is_redirect=0 " .
SpecialNewpages.php:32: AND rc_namespace=0 AND cur_is_redirect=0";
SpecialPopularpages.php:23: WHERE cur_namespace=0 AND cur_is_redirect=0";
SpecialRandompage.php:21: WHERE cur_namespace=0 AND cur_is_redirect=0 $extra
SpecialRecentchanges.php:49: $sql = "SELECT cur_text FROM cur WHERE
cur_namespace=4 AND cur_title='Recentchanges'";
SpecialShortpages.php:26: WHERE cur_namespace=0 AND cur_is_redirect=0";
SpecialUncategorizedpages.php:22: "WHERE cl_from IS NULL AND cur_namespace=0
AND cur_is_redirect=0";
SpecialUndelete.php:128: $log = wfGetSQL("cur", "cur_text", "cur_namespace=4
AND cur_title='".
SpecialWatchlist.php:143: $z = "(wl_namespace=cur_namespace OR
wl_namespace+1=cur_namespace)";


Version: 1.3.x
Severity: trivial

Details

Reference
bz696

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 6:57 PM
bzimport set Reference to bz696.
bzimport added a subscriber: Unknown Object (MLST).

wmahan_04 wrote:

(In reply to comment #0)

Most of these assume the main namespace will always be 0.

But the main namespace _is_ always 0, so it seems like a
non-issue to me. If you were to supply a patch against HEAD,
I doubt anyone would object to it, but I'm not sure it's
worth the effort.

qleah wrote:

(In reply to comment #1)

(In reply to comment #0)

Most of these assume the main namespace will always be 0.

But the main namespace _is_ always 0, so it seems like a
non-issue to me. If you were to supply a patch against HEAD,
I doubt anyone would object to it, but I'm not sure it's
worth the effort.

It shouldn't be arbitrarily decided that namespace 0 can never be used for
anything else. It may be the main article namespace on every Wikimedia site,
but somebody else might prefer a different namespace layout. The direct
references to namespace 0 should be fixed before they lead to maintenance headaches.

wmahan_04 wrote:

(In reply to comment #2)

It shouldn't be arbitrarily decided that namespace 0 can never be used for
anything else. It may be the main article namespace on every Wikimedia site,
but somebody else might prefer a different namespace layout. The direct
references to namespace 0 should be fixed before they lead to maintenance

headaches.

Would you mind making a patch for this?

qleah wrote:

(In reply to comment #3)

(In reply to comment #2)

It shouldn't be arbitrarily decided that namespace 0 can never be used for
anything else. It may be the main article namespace on every Wikimedia site,
but somebody else might prefer a different namespace layout. The direct
references to namespace 0 should be fixed before they lead to maintenance

headaches.

Would you mind making a patch for this?

I'd thought of it, but I'm not really familiar enough with all the code to be
certain I wouldn't inadvertently break something somewhere.

I am making some changes in HEAD sources but it's probably not
worth it. People should not change the NS_MAIN value in defines.php
(I added a note about that).

I think we should use 0 as an alias for NS_MAIN wherever it is convenient. The
aim is to break enough things such that clueless users who think they can change
it will be discouraged quickly, rather than suffer a long and painful array of
minor bugs. Using NS_MAIN is useful for self-documentation, to indicate that the
zero is a namespace. It's not useful for flexibility.

hashar added a comment.Dec 4 2005, 2:06 PM

wont fix as per comment 5 & 6