Followup rr86304
authorSam Reed <reedy@users.mediawiki.org>
Mon, 18 Apr 2011 14:02:13 +0000 (14:02 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 18 Apr 2011 14:02:13 +0000 (14:02 +0000)
We need a title object for parsing, do one against the message key

Doesn't seem to be the best way, but it's the most applicable. If I abused $wgTitle, Chad would come and beat me too ;)

includes/GlobalFunctions.php
includes/Message.php
includes/MessageCache.php

index d71c72b..c88c89a 100644 (file)
@@ -719,7 +719,7 @@ function wfMsgWikiHtml( $key ) {
        $args = func_get_args();
        array_shift( $args );
        return wfMsgReplaceArgs(
-               MessageCache::singleton()->parse( wfMsgGetKey( $key, true ), null, /* can't be set to false */ true )->getText(),
+               MessageCache::singleton()->parse( wfMsgGetKey( $key, true ), $key, /* can't be set to false */ true )->getText(),
                $args );
 }
 
@@ -781,9 +781,9 @@ function wfMsgExt( $key, $options ) {
 
        $messageCache = MessageCache::singleton();
        if( in_array( 'parse', $options, true ) ) {
-               $string = $messageCache->parse( $string, null, true, !$forContent, $langCodeObj )->getText();
+               $string = $messageCache->parse( $string, $key, true, !$forContent, $langCodeObj )->getText();
        } elseif ( in_array( 'parseinline', $options, true ) ) {
-               $string = $messageCache->parse( $string, null, true, !$forContent, $langCodeObj )->getText();
+               $string = $messageCache->parse( $string, $key, true, !$forContent, $langCodeObj )->getText();
                $m = array();
                if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
                        $string = $m[1];
index 69a48b8..d65ec86 100644 (file)
@@ -432,7 +432,7 @@ class Message {
         * @return string Wikitext parsed into HTML
         */
        protected function parseText( $string ) {
-               return MessageCache::singleton()->parse( $string, null, /*linestart*/true, $this->interface, $this->language )->getText();
+               return MessageCache::singleton()->parse( $string, $this->key, /*linestart*/true, $this->interface, $this->language )->getText();
        }
 
        /**
index bd04801..34eaa6d 100644 (file)
@@ -790,13 +790,13 @@ class MessageCache {
 
        /**
         * @param $text string
-        * @param $title Title
+        * @param $string Title|string
         * @param $interface bool
         * @param $linestart bool
         * @param $language
         * @return ParserOutput
         */
-       public function parse( $text, $title = null, $linestart = true, $interface = false, $language = null  ) {
+       public function parse( $text, $key, $linestart = true, $interface = false, $language = null  ) {
                if ( $this->mInParser ) {
                        return htmlspecialchars( $text );
                }
@@ -811,6 +811,9 @@ class MessageCache {
                        $popts->setTargetLanguage( $language );
                }
 
+               if ( !($key instanceof Title) ) {
+                       $title = Title::newFromText( $key, NS_MEDIAWIKI );
+               }
                $this->mInParser = true;
                $res = $parser->parse( $text, $title, $popts, $linestart );
                $this->mInParser = false;