From efeecf08a1f57ea5fa0b3bb0fa5197889efa0534 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sat, 31 Jan 2009 17:00:23 +0000 Subject: [PATCH] Substitute variables and parse grammar also on NS_PROJECT_TALK aliases, as it is used quite often. Ref: bug 17267 --- languages/Language.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index 0d3c76e867..d9874feb74 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2565,16 +2565,8 @@ class Language { $this->namespaceNames[NS_PROJECT_TALK] = $wgMetaNamespaceTalk; } else { $talk = $this->namespaceNames[NS_PROJECT_TALK]; - $talk = str_replace( '$1', $wgMetaNamespace, $talk ); - - # Allow grammar transformations - # Allowing full message-style parsing would make simple requests - # such as action=raw much more expensive than they need to be. - # This will hopefully cover most cases. - $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i', - array( &$this, 'replaceGrammarInNamespace' ), $talk ); - $talk = str_replace( ' ', '_', $talk ); - $this->namespaceNames[NS_PROJECT_TALK] = $talk; + $this->namespaceNames[NS_PROJECT_TALK] = + $this->fixVariableInNamespace( $talk ); } # The above mixing may leave namespaces out of canonical order. @@ -2591,6 +2583,9 @@ class Language { } if ( $this->namespaceAliases ) { foreach ( $this->namespaceAliases as $name => $index ) { + if ( $index === NS_PROJECT_TALK ) { + $name = $this->fixVariableInNamespace( $name ); + } $this->mNamespaceIds[$this->lc($name)] = $index; } } @@ -2606,6 +2601,21 @@ class Language { wfProfileOut( __METHOD__ ); } + function fixVariableInNamespace( $talk ) { + if ( strpos( $talk, '$1' ) === false ) return $talk; + + global $wgMetaNamespace; + $talk = str_replace( '$1', $wgMetaNamespace, $talk ); + + # Allow grammar transformations + # Allowing full message-style parsing would make simple requests + # such as action=raw much more expensive than they need to be. + # This will hopefully cover most cases. + $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i', + array( &$this, 'replaceGrammarInNamespace' ), $talk ); + return str_replace( ' ', '_', $talk ); + } + function replaceGrammarInNamespace( $m ) { return $this->convertGrammar( trim( $m[2] ), trim( $m[1] ) ); } -- 2.20.1