Last modified: 2010-05-15 15:38:17 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 2287 - {{ns:##}} makes php to print notices if namespace doesn't exists
{{ns:##}} makes php to print notices if namespace doesn't exists
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.5.x
All All
: Normal trivial with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 2140 2321 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-01 21:31 UTC by Niklas Laxström
Modified: 2010-05-15 15:38 UTC (History)
1 user (show)

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


Attachments
Proposed patch (857 bytes, patch)
2005-06-01 21:33 UTC, Niklas Laxström
Details

Description Niklas Laxström 2005-06-01 21:31:45 UTC
The code replacing {{ns:##}} with namespace names doesn't check if the namespace
exists but directly accesses the array, which of course makes php to produces
notices about undefined index.
Comment 1 Niklas Laxström 2005-06-01 21:33:21 UTC
Created attachment 584 [details]
Proposed patch
Comment 2 Niklas Laxström 2005-06-04 15:48:12 UTC
*** Bug 2321 has been marked as a duplicate of this bug. ***
Comment 3 lɛʁi לערי ריינהארט 2005-06-04 16:11:00 UTC
This relates also to configurations where only one namespace is defined, where
primary or talk namespace is missing. Eighter the tags "primary" or "talk" can
generate the php error.

Regards Reinhardt
Comment 4 Jamie Bliss 2005-06-04 21:34:17 UTC
(In reply to comment #3)
> This relates also to configurations where only one namespace is defined, where
> primary or talk namespace is missing. Eighter the tags "primary" or "talk" can
> generate the php error.

Not necessarily. In my case, it was generated by namespaces -3, 16, 17, 102, and
103, which are in article/talk pairs (except -3, which is a non-existant
psuedo-namespace).

This error is generated whenever Language::getNsText() is called. For example,
the PHP code
 $badtitle = Title::makeName(42, 'foo_bar');
Will generate the error.

Nothing is wrong with the parser, just a simple check in Language::getNsText()
is needed (Language.php, line 1725-1728 in 1.4.4). I believe array_key_exists()
would be the function.
Comment 5 Niklas Laxström 2005-06-04 21:41:17 UTC
(In reply to comment #4)
> Nothing is wrong with the parser, just a simple check in Language::getNsText()
> is needed (Language.php, line 1725-1728 in 1.4.4). I believe array_key_exists()
> would be the function.

That function is overwritten in other language files. In my opinion it's easier
to fix it once in Parser than in every existing and new language file.
Comment 6 Jamie Bliss 2005-06-04 21:51:25 UTC
(In reply to comment #5)
> That function is overwritten in other language files. In my opinion it's easier
> to fix it once in Parser than in every existing and new language file.

If something goes wrong with an extension, or the DB is modified, or some other
internal error, it still will come up.

Fix the bug at the source, don't hack around it. (And yes, I know how many
language files there are.)
Comment 7 Jamie Bliss 2005-06-06 19:25:29 UTC
(My apologies for a harsh reply in #6)

Try something like this:
	function getNsText( $index ) {
		$NamespaceNames = $this->getNamespaces();
		if (!isset($NamespaceNames[$index])) return '';
		return $NamespaceNames[$index];
	}

Then you just have to remove the function in the other files. (Assuming nothing
funny is going on.) A similar thing should probably be done for
Language::getNsIndex() as well.
Comment 8 Niklas Laxström 2005-06-06 19:34:44 UTC
(In reply to comment #7)
Indeed that seems to be the best solution.
Comment 9 Ævar Arnfjörð Bjarmason 2005-06-18 04:09:37 UTC
I modified the code suggested by Jamie and applied it to HEAD, marking it as FIXED.
Comment 10 Ævar Arnfjörð Bjarmason 2005-06-24 13:20:27 UTC
*** Bug 2140 has been marked as a duplicate of this bug. ***

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


Navigation
Links