20 $contLang = Language::factory(
'en' );
22 'wgShowExceptionDetails' =>
true,
23 'wgCleanSignatures' =>
true,
29 $this->
options = ParserOptions::newFromUserAndLang(
new User, $contLang );
30 $this->
options->setTemplateCallback( [ __CLASS__,
'statelessFetchTemplate' ] );
31 $this->parser =
new Parser;
33 MediaWikiServices::getInstance()->resetServiceForTesting(
'MagicWordFactory' );
41 $longLine =
'1.' .
str_repeat(
'1234567890', 100000 ) .
"\n";
43 $title = Title::newFromText(
'Unit test' );
46 $this->parser->parse( $longLine, $title,
$options )->getText( [
'unwrap' =>
true ] ) );
54 $text =
"{{Special:ApiHelp/help}}";
55 $title = Title::newFromText(
'testSpecialPageTransclusionRestoresGlobalState' );
58 RequestContext::getMain()->setTitle( $title );
59 RequestContext::getMain()->getWikiPage()->CustomTestProp =
true;
61 $parsed = $this->parser->parse( $text, $title,
$options )->getText();
65 $this->
assertTrue( RequestContext::getMain()->getWikiPage()->CustomTestProp );
73 $title = Title::newFromText( __FUNCTION__ );
74 $parserOutput = $this->parser->parse(
"Test\n{{Foo}}\n{{Bar}}", $title, $this->
options );
76 "<p>Test\nContent of <i>Template:Foo</i>\nContent of <i>Template:Bar</i>\n</p>",
77 $parserOutput->getText( [
'unwrap' =>
true ] )
85 $title = Title::newFromText( __FUNCTION__ );
86 $outputText = $this->parser->preSaveTransform(
87 "Test\r\n{{subst:Foo}}\n{{Bar}}",
93 $this->
assertEquals(
"Test\nContent of ''Template:Foo''\n{{Bar}}", $outputText );
100 $title = Title::newFromText( __FUNCTION__ );
101 $outputText = $this->parser->preprocess(
"Test\n{{Foo}}\n{{Bar}}", $title, $this->
options );
104 "Test\nContent of ''Template:Foo''\nContent of ''Template:Bar''",
114 $title = Title::newFromText( __FUNCTION__ );
115 $outputText = $this->parser->cleanSig(
"{{Foo}} ~~~~" );
127 $title = Title::newFromText( __FUNCTION__ );
128 $outputText = $this->parser->cleanSig(
"{{Foo}} ~~~~" );
144 [
"{{Foo}} ~~~~",
"{{Foo}} " ],
154 $outputText2 = $this->parser->getSection(
155 "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
156 .
"Section 2\n== Heading 3 ==\nSection 3\n",
159 $outputText1 = $this->parser->getSection(
160 "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
161 .
"Section 2\n== Heading 3 ==\nSection 3\n",
165 $this->
assertEquals(
"=== Heading 2 ===\nSection 2", $outputText2 );
166 $this->
assertEquals(
"== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2", $outputText1 );
173 $outputText = $this->parser->replaceSection(
174 "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
175 .
"Section 2\n== Heading 3 ==\nSection 3\n",
180 $this->
assertEquals(
"Section 0\nNew section 1\n\n== Heading 3 ==\nSection 3", $outputText );
188 $title = Title::newFromText( __FUNCTION__ );
189 $outputText = $this->parser->getPreloadText(
190 "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->",
195 $this->
assertEquals(
"{{Foo}} information <!-- is very secret -->", $outputText );
205 $text =
"Content of ''" . $title->getFullText() .
"''";
218 $title = Title::newFromText( __FUNCTION__ );
219 $catName =
wfMessage(
'broken-file-category' )->inContentLanguage()->text();
220 $cat = Title::makeTitleSafe(
NS_CATEGORY, $catName );
221 $expected = [ $cat->getDBkey() ];
222 $parserOutput = $this->parser->parse(
"[[file:nonexistent]]", $title, $this->
options );
223 $result = $parserOutput->getCategoryLinks();
232 $title = SpecialPage::getTitleFor(
'Contributions' );
233 $parserOutput = $this->parser->parse(
"[[file:nonexistent]]", $title, $this->
options );
234 $result = $parserOutput->getCategoryLinks();
243 $this->parser->startExternalParse( Title::newFromText( __FUNCTION__ ),
244 $this->
options, Parser::OT_HTML );
249 if ( $expected[0] ===
'link-title' ) {
255 foreach ( $expectedLinks as $func => $expected ) {
256 $output = $this->parser->getOutput()->$func();
265 [
'no-link',
false ],
267 'Return no link when requested',
270 'https://example.com/',
271 [
'link-url',
'https://example.com/' ],
272 [
'getExternalLinks' => [
'https://example.com/' => 1 ] ],
277 [
'link-url',
'//example.com/' ],
278 [
'getExternalLinks' => [
'//example.com/' => 1 ] ],
283 [
'link-title', Title::newFromText(
'Test' ) ],
284 [
'getLinks' => [ 0 => [
'Test' => 0 ] ] ],
289 [
'link-title', Title::newFromText(
'mw:Test' ) ],
290 [
'getInterwikiLinks' => [
'mw' => [
'Test' => 1 ] ] ],
291 'Internal link (interwiki)',
297 'Invalid link target',
303 'Invalid link target',
309 'Invalid link target',
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Set options of the Parser.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
namespace and then decline to actually register it file or subcat img or subcat $title
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
processing should stop and the error should be shown to the user * false
if(is_array($mode)) switch( $mode) $input