r71327 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71326‎ | r71327 | r71328 >
Date:05:32, 20 August 2010
Author:werdna
Status:ok (Comments)
Tags:
Comment:
(bug 24837) Fix issue where namespaces which were localised but not defined were returned by Language::getNamespaces()
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -256,6 +256,14 @@
257257 $this->namespaceNames[NS_PROJECT_TALK] =
258258 $this->fixVariableInNamespace( $talk );
259259 }
 260+
 261+ # Sometimes a language will be localised but not actually exist on this wiki.
 262+ $validNamespaces = MWNamespace::getValidNamespaces();
 263+ foreach( $this->namespaceNames as $key => $text ) {
 264+ if ( ! in_array( $key, $validNamespaces ) ) {
 265+ unset( $this->namespaceNames[$key] );
 266+ }
 267+ }
260268
261269 # The above mixing may leave namespaces out of canonical order.
262270 # Re-order by namespace ID number...

Follow-up revisions

RevisionCommit summaryAuthorDate
r71328Merge r71327, fix for Language::getNamespaces bug exposed by localising Liqui...werdna05:36, 20 August 2010
r71329Follow-up to r71328, turns out from testing on test.wikipedia.org that MWName...werdna05:43, 20 August 2010
r71330Apply hack from 1.16wmf4 in r71329 to trunk (follow-up to r71327). The versio...werdna06:19, 20 August 2010

Comments

#Comment by Catrope (talk | contribs)   11:52, 27 September 2010
+			$validNamespaces = MWNamespace::getValidNamespaces();
+			foreach( $this->namespaceNames as $key => $text ) {
+			        if ( ! in_array( $key, $validNamespaces ) ) {
+			                unset( $this->namespaceNames[$key] );
+			        }
+			}

Can't you just use array_diff_key() here instead of rolling your own?

#Comment by Werdna (talk | contribs)   12:08, 27 September 2010

Possibly, but I had no idea that that function existed. My version is probably more readable without the PHP manual, too.

Status & tagging log