Extension talk:RawMsg

From mediawiki.org
Latest comment: 9 years ago by 2nd in topic MediaWiki 1.19a fatal error

pre and p tags are added to the code[edit]

I tried to use this extension to insert Google AJAX Search API to a wiki, but there were some pre and p tags generated and spaces were turned into & nbsp ; which stopped the code from working. Any idea to get REAL RAW msg?

Use {{msgnw:pagename}}
For example
<code style="white-space:pre">



But note that if msgnw effectively pastes the raw characters, theyr are still feeding the MediaWiki parser, which will compress blanks in its output (because these blanks are parsed and will generate paragraphs, lists (you cannot disable this unless you use "nowiki" tags around it, but then the msgnw function is also not interpreted and you don't get its output result);

<code style="white-space:pre">


<onlyinclude><span class="phui-tag-wrapper"><templatestyles src="Template:T/styles.css"/><includeonly>[[phab:T{{{1}}}|</includeonly><span class="phui-tag-core">T{{{1}}}{{#if:{{{2|<noinclude>1</noinclude>}}}|&#58; {{{2}}}}}</span><includeonly>]]</includeonly></span></onlyinclude> {{Documentation}} <!-- Add categories to the /doc subpage and interwikis in Wikidata, not here! -->

There's still no way to force msgnw to output its result in a nowiki section that it generates itself, you'll have to use a Lua module to reencode the output of msgnw with a "mwencode" function to change the problematic characters into numeric entities; the alternative is to use "urlencode" to see that the result of msgnw was effectively raw (a NEWLINE will be shown as %0A, a SPACE will be "+", most punctuations are %nn-encoded, and non-ASCII characters are %nn-encoded byte per byte in hexadecimal, according to their UTF-8 encoding) so

<code style="white-space:pre">



MediaWiki 1.19a fatal error[edit]

On MediaWiki 1.19a I'm seeing the following code fail with a fatal error, effectively shutting down the entire wiki:

# Add system messages
 global $wgMessageCache;
 $wgMessageCache->addMessage('rawmsg-missing-params', 'Error: <nowiki>{{#rawmsg:}}</nowiki> is missing a required parameter.');
 $wgMessageCache->addMessage('rawmsg-missing-article', 'Error: RawMsg cannot find the article [[MediaWiki:rawmsg-$1]].');

failing with:

PHP Fatal error: Call to a member function addMessage() on a non-object in /home/sophia/domains/extensions/RawMsg.php on line 73

$wgMessageCache is deprecated with a big fat This feature was removed completely in version 1.18.0 in the manual. This extension is therefore now broken, short of removing these lines and creating MediaWiki:rawmsg-missing-params, MediaWiki:rawmsg-missing-article manually. --Carlb 01:54, 14 February 2012 (UTC)Reply[reply]

I added a RawMsg.i18n.php file with the contents

$messages = array();
$messages['en'] = array(
    'rawmsg-missing-params' => 'Error: <nowiki>{{#rawmsg:}}</nowiki> is missing a required parameter.',
    'rawmsg-missing-article' => 'Error: RawMsg cannot find the article [[MediaWiki:rawmsg-$1]].',

commented out the three lines with $wgMessageCache, and added this line to RawMsg.php (after the $wgExtensionCredits part):

$wgExtensionMessagesFiles['RawMsg'] = dirname( __FILE__ ) . '/RawMsg.i18n.php';

This seems to work nicely (1.18.1). --Tgr (talk) 09:40, 26 February 2012 (UTC)Reply[reply]

$messages['ru'] = array(
    'rawmsg-missing-params' => 'Ошибка: <nowiki>{{#rawmsg:}}</nowiki> параметр отсутствует.',
    'rawmsg-missing-article' => 'Ошибка: RawMsg не может найти статью [[MediaWiki:rawmsg-$1]].',

--2nd 12:56, 30 June 2014 (UTC)Reply[reply]