Last modified: 2010-05-15 15:32:54 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T4421, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 2421 - Uninitialised array entries in $wgNamespacesWithSubpages,wgNamespacesToBeSearchedDefault
Uninitialised array entries in $wgNamespacesWithSubpages,wgNamespacesToBeSear...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.4.x
PC Windows 2000
: Normal minor with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
http://meta.wikimedia.org/wiki/Help:L...
:
Depends on:
Blocks: code_quality
  Show dependency treegraph
 
Reported: 2005-06-16 00:23 UTC by Jason Armistead
Modified: 2010-05-15 15:32 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jason Armistead 2005-06-16 00:24:00 UTC
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.

i.e.

$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
Comment 1 Brion Vibber 2005-06-16 00:27:59 UTC
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.
Comment 2 Brion Vibber 2005-06-16 08:21:48 UTC
Done. Also switched from 1 to true.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links