Page MenuHomePhabricator

Uninitialised array entries in $wgNamespacesWithSubpages,wgNamespacesToBeSearchedDefault
Closed, ResolvedPublic


Author: Jason.Armistead

Looking at Language.php, it is clear that we now have 16 + 2 = 18 namespaces.

Yet in DefaultSettings.php, you do not initialise all the elements in the
$wgNamespacesWithSubpages array.


$wgNamespacesWithSubpages = array( -1 => 0, 0 => 0, 1 => 1,

2 => 1, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 1, 8 => 0, 9 => 1, 10 => 0, 11 => 1);

which is only the first 12 namespaces plus Special.

As a good programming practise, it would be appropriate to initialise ALL values in this array to
something meaningful. Currently namespaces -2 (Media), and 12-15 (Help, Help_Talk, Category and
Category_Talk) do not get a specifically assigned entry in the array.

The next statement in DefaultSettings.php relating to $wgNamespacesToBeSearchedDefault has a
similar problem.

I think this stems from the growth of MediaWiki from 12 to 16 namespaces (plus the two negative-
numbered special spaces).

And while the comment above these two statements says

See Language.php for a list of namespaces.

It would also make some sense to provide a pointer to a list of the namespace NUMBERS, which is,
after all, what the arrays are initialised using (rather than namespace NAMES). These definitions
are laid out in module Defines.php

Version: 1.4.x
Severity: minor
OS: Windows 2000
Platform: PC



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:34 PM
bzimport set Reference to bz2421.
bzimport added a subscriber: Unknown Object (MLST).

iirc these arrays need only include positive entries; anything else (including custom
namespaces) will be taken as negative.

Unless it's triggering uninitialized array item access notices this is just a code
readability issue; adding to the code quality tracking bug 700.

The default values for the arrays should include only positive entries and use the NS_*
symbolic constants.

brion added a comment.Jun 16 2005, 8:21 AM

Done. Also switched from 1 to true.