r46648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46647‎ | r46648 | r46649 >
Date:17:00, 31 January 2009
Author:nikerabbit
Status:deferred (Comments)
Tags:
Comment:
Substitute variables and parse grammar also on NS_PROJECT_TALK aliases, as it is used quite often. Ref: bug 17267
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -2565,16 +2565,8 @@
25662566 $this->namespaceNames[NS_PROJECT_TALK] = $wgMetaNamespaceTalk;
25672567 } else {
25682568 $talk = $this->namespaceNames[NS_PROJECT_TALK];
2569 - $talk = str_replace( '$1', $wgMetaNamespace, $talk );
2570 -
2571 - # Allow grammar transformations
2572 - # Allowing full message-style parsing would make simple requests
2573 - # such as action=raw much more expensive than they need to be.
2574 - # This will hopefully cover most cases.
2575 - $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
2576 - array( &$this, 'replaceGrammarInNamespace' ), $talk );
2577 - $talk = str_replace( ' ', '_', $talk );
2578 - $this->namespaceNames[NS_PROJECT_TALK] = $talk;
 2569+ $this->namespaceNames[NS_PROJECT_TALK] =
 2570+ $this->fixVariableInNamespace( $talk );
25792571 }
25802572
25812573 # The above mixing may leave namespaces out of canonical order.
@@ -2591,6 +2583,9 @@
25922584 }
25932585 if ( $this->namespaceAliases ) {
25942586 foreach ( $this->namespaceAliases as $name => $index ) {
 2587+ if ( $index === NS_PROJECT_TALK ) {
 2588+ $name = $this->fixVariableInNamespace( $name );
 2589+ }
25952590 $this->mNamespaceIds[$this->lc($name)] = $index;
25962591 }
25972592 }
@@ -2606,6 +2601,21 @@
26072602 wfProfileOut( __METHOD__ );
26082603 }
26092604
 2605+ function fixVariableInNamespace( $talk ) {
 2606+ if ( strpos( $talk, '$1' ) === false ) return $talk;
 2607+
 2608+ global $wgMetaNamespace;
 2609+ $talk = str_replace( '$1', $wgMetaNamespace, $talk );
 2610+
 2611+ # Allow grammar transformations
 2612+ # Allowing full message-style parsing would make simple requests
 2613+ # such as action=raw much more expensive than they need to be.
 2614+ # This will hopefully cover most cases.
 2615+ $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
 2616+ array( &$this, 'replaceGrammarInNamespace' ), $talk );
 2617+ return str_replace( ' ', '_', $talk );
 2618+ }
 2619+
26102620 function replaceGrammarInNamespace( $m ) {
26112621 return $this->convertGrammar( trim( $m[2] ), trim( $m[1] ) );
26122622 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r46656Followup to r46648 and fix for bug 17267: when expanding $1 in namespace alia...catrope20:12, 31 January 2009

Comments

#Comment by Werdna (talk | contribs)   23:52, 11 February 2009

Some fixes in r46656, "Followup to r46648 and fix for bug 17267: when expanding $1 in namespace aliases, actually store the 'new' alias back in the $wgContLang->namespaceAliases array"

Status & tagging log