MediaWiki r41876 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r41875‎ | r41876 (on ViewVC)‎ | r41877 >
Date:00:56, 9 October 2008
Author:vyznev
Status:old (Comments)
Tags:
Comment:
Make the {{ns:}} core parser function accept localized namespace names and aliases. Also change the output to use spaces
instead of underscores so that it matches the output of {{NAMESPACE}} and related magic words.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -68,20 +68,13 @@
6969
7070 static function ns( $parser, $part1 = '' ) {
7171 global $wgContLang;
72 - $found = false;
7372 if ( intval( $part1 ) || $part1 == "0" ) {
74 - $text = $wgContLang->getNsText( intval( $part1 ) );
75 - $found = true;
 73+ $index = intval( $part1 );
7674 } else {
77 - $param = str_replace( ' ', '_', strtolower( $part1 ) );
78 - $index = MWNamespace::getCanonicalIndex( strtolower( $param ) );
79 - if ( !is_null( $index ) ) {
80 - $text = $wgContLang->getNsText( $index );
81 - $found = true;
82 - }
 75+ $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) );
8376 }
84 - if ( $found ) {
85 - return $text;
 77+ if ( $index !== false ) {
 78+ return $wgContLang->getFormattedNsText( $index );
8679 } else {
8780 return array( 'found' => false );
8881 }
Index: trunk/phase3/RELEASE-NOTES
@@ -158,6 +158,9 @@
159159 solutions such as CSS-based overlays and ImageMap.
160160 * (bug 368) Don't use caption for alt attribute; allow manual specification
161161 using new "alt=" parameter for images
 162+* (bug 44) The {{ns:}} core parser function now also accepts localized namespace
 163+ names and aliases; also, its output now uses spaces instead of underscores to
 164+ match the behavior of the {{NAMESPACE}} magic word
162165
163166 === Bug fixes in 1.14 ===
164167

Comments

#Comment by Brion VIBBER (talk | contribs)   20:21, 9 October 2008

Hmm... my one concern here is that Template:Ns:Foo using a localized name won't be portable across wikis in different languages.

#Comment by Ilmari Karonen (talk | contribs)   05:34, 10 October 2008

Doesn't the old punchline "Well, don't do that, then." apply? Normal wikilinks using localized namespace names break the same way. So does {{ns:Portal}}, if you try to use it on a wiki without a "Portal" namespace. One would and should expect the same to happen if you use {{ns:}} with a localized namespace name on a different-language wiki. That doesn't mean it can't be a useful feature (even if it's really just a side effect), especially for wikis with actual localized namespace aliases (i.e. more than one localized name mapping to the same namespace).

#Comment by Siebrand (talk | contribs)   09:07, 10 October 2008

Agreed with Ilmari's remark. The same goes for the localisation of magic words. Using those will also prevent code from being portable to a wiki that has a wgLang different from default ('en') or the source wgLang.

#Comment by Brion VIBBER (talk | contribs)   01:05, 13 October 2008

fair enough :)

Status & tagging log

  • 00:58, 18 January 2012 Siebrand (talk | contribs) changed the tags for r41876 [removed: suspicious]
  • 15:32, 12 September 2011 Meno25 (talk | contribs) changed the status of r41876 [removed: ok added: old]
  • 12:50, 2 April 2011 Happy-melon (talk | contribs) changed the tags for r41876 [removed: bug44]