[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 Bawolff changed: What|Removed |Added CC||markus@semantic-mediawiki.o ||rg --- Comment #6 from Bawolff 2012-04-15 04:22:08 UTC --- *** Bug 14959 has been marked as a duplicate of this bug. *** -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 Reedy changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Comment #5 from Reedy 2011-04-18 12:44:37 UTC --- r86304 -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 Reedy changed: What|Removed |Added Attachment #8406|0 |1 is obsolete|| --- Comment #4 from Reedy 2011-04-18 12:44:14 UTC --- Comment on attachment 8406 --> https://bugzilla.wikimedia.org/attachment.cgi?id=8406 Patch >Index: GlobalFunctions.php >=== >--- GlobalFunctions.php(revision 86120) >+++ GlobalFunctions.php(working copy) >@@ -716,10 +716,12 @@ > * @return string > */ > function wfMsgWikiHtml( $key ) { >- global $wgOut; >+ global $wgMessageCache; > $args = func_get_args(); > array_shift( $args ); >- return wfMsgReplaceArgs( $wgOut->parse( wfMsgGetKey( $key, true ), /* >can't be set to false */ true ), $args ); >+ return wfMsgReplaceArgs( >+ $wgMessageCache->parse( wfMsgGetKey( $key, true ), null, /* >can't be set to false */ true ), >+ $args ); > } > > /** >@@ -741,7 +743,7 @@ > * Behavior for conflicting options (e.g., parse+parseinline) is undefined. > */ > function wfMsgExt( $key, $options ) { >- global $wgOut; >+ global $wgMessageCache; > > $args = func_get_args(); > array_shift( $args ); >@@ -781,9 +783,9 @@ > } > > if( in_array( 'parse', $options, true ) ) { >- $string = $wgOut->parse( $string, true, !$forContent, >$langCodeObj ); >+ $string = $wgMessageCache->parse( $string, null, true, >!$forContent, $langCodeObj ); > } elseif ( in_array( 'parseinline', $options, true ) ) { >- $string = $wgOut->parse( $string, true, !$forContent, >$langCodeObj ); >+ $string = $wgMessageCache->parse( $string, null, true, >!$forContent, $langCodeObj ); > $m = array(); > if( preg_match( '/^(.*)\n?<\/p>\n?$/sU', $string, $m ) ) { > $string = $m[1]; >Index: MessageCache.php >=== >--- MessageCache.php (revision 86120) >+++ MessageCache.php (working copy) >@@ -102,6 +102,8 @@ > > /** >* ParserOptions is lazy initialised. >+ * >+ * @return ParserOptions >*/ > function getParserOptions() { > if ( !$this->mParserOptions ) { >@@ -220,6 +222,8 @@ > > /** >* Set the cache to $cache, if it is valid. Otherwise set the cache to > false. >+ * >+ * @return bool >*/ > function setCache( $cache, $code ) { > if ( isset( $cache['VERSION'] ) && $cache['VERSION'] == > MSG_CACHE_VERSION ) { >@@ -734,6 +738,21 @@ > return $message; > } > >+ $parser = $this->getParser(); >+ if ( $parser ) { >+ $popts = $this->getParserOptions(); >+ $popts->setInterfaceMessage( $interface ); >+ $popts->setTargetLanguage( $language ); >+ $popts->setUserLang( $language ); >+ $message = $parser->transformMsg( $message, $popts, >$title ); >+ } >+ return $message; >+ } >+ >+ /** >+ * @return Parser >+ */ >+ function getParser() { > global $wgParser, $wgParserConf; > if ( !$this->mParser && isset( $wgParser ) ) { > # Do some initialisation so that we don't have to do it > twice >@@ -746,16 +765,28 @@ > } else { > $this->mParser = clone $wgParser; > } >- #wfDebug( __METHOD__ . ": following contents triggered >transform: $message\n" ); > } >- if ( $this->mParser ) { >- $popts = $this->getParserOptions(); >- $popts->setInterfaceMessage( $interface ); >+ return $this->mParser; >+ } >+ >+ /** >+ * @param $text string >+ * @param $title >+ * @param $linestart bool >+ * @return ParserOutput >+ */ >+ public function parse( $text, $title = null, $linestart = true, >$interface = false, $language = null ) { >+ $parser = $this->getParser(); >+ $popts = $this->getParserOptions(); >+ >+ if ( $interface ) { >+ $popts->setInterfaceMessage( true ); >+ } >+ if ( $language !== null ) { > $popts->setTargetLanguage( $language ); >- $popts->setUserLang( $language ); >- $message = $this->mParser->transformMsg( $message, >$popts, $title ); > } >- return $message; >+ >+ return $parser->parse( $text, $title, $pop
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 --- Comment #3 from Tim Starling 2011-04-18 00:43:11 UTC --- (In reply to comment #1) > Created attachment 8406 [details] > Patch > > Rather than committing and waiting for review, seemed sensible to create a > patch and put here for you to look at Tim, being an area of code I'm not > really > familiar with That's the general idea, but MessageCache::parse() lacks protection against re-entrant calls. You need something like: if ( $this->mInParser ) { return htmlspecialchars( $in ); } $this->mInParser = true; $this->mParser->parse(...); $this->mInParser = false; Both MessageCache::transform() and MessageCache::parse() should be protected using the same member variable, since they both access the same parser object. You could test it by making a couple of tag hook extensions that call $wgMessageCache->parse(). [[test]] It's easy enough to make a tag hook extension in a few lines of code in LocalSettings.php, you don't need to make a separate file or anything. Please also patch Message::parseText() to call MessageCache::singleton()->parse(), so that Niklas's idea can easily be done later. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 --- Comment #2 from Niklas Laxström 2011-04-15 17:46:37 UTC --- I'd rather see wfMessage being fixed and wfMsg* slowly converted to deprecated wrappers around wfMessage. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 Reedy changed: What|Removed |Added Blocks||16129 -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 Reedy changed: What|Removed |Added Keywords||need-review, patch -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
[Bug 28532] wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
https://bugzilla.wikimedia.org/show_bug.cgi?id=28532 --- Comment #1 from Reedy 2011-04-15 17:42:47 UTC --- Created attachment 8406 --> https://bugzilla.wikimedia.org/attachment.cgi?id=8406 Patch Rather than committing and waiting for review, seemed sensible to create a patch and put here for you to look at Tim, being an area of code I'm not really familiar with -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l