18 return $updater->saveRevision( CommentStoreComment::newUnsavedComment(
'testing' ) );
22 $options = ParserOptions::newCanonical(
'canonical' );
29 $this->assertContains(
'First', $work->getParserOutput()->getText() );
33 $this->assertContains(
'Second', $work->getParserOutput()->getText() );
37 $options = ParserOptions::newCanonical(
'canonical' );
44 $cache = MediaWikiServices::getInstance()->getParserCache();
47 $this->assertNotNull(
$out );
48 $this->assertNotFalse(
$out );
49 $this->assertContains(
'First',
$out->getText() );
53 $options = ParserOptions::newCanonical(
'canonical' );
59 $fakeRev->setId(
$rev->getId() );
60 $fakeRev->setPageId( $page->getId() );
61 $fakeRev->setContent( SlotRecord::MAIN,
new WikitextContent(
'YES!' ) );
66 $text = $work->getParserOutput()->getText();
67 $this->assertContains(
'YES!', $text );
68 $this->assertNotContains(
'NOPE', $text );
72 $options = ParserOptions::newCanonical(
'canonical' );
80 $text = $work->getParserOutput()->getText();
81 $this->assertContains(
'YES!', $text );
85 $options = ParserOptions::newCanonical(
'canonical' );
91 $text = $work->getParserOutput()->getText();
92 $this->assertContains(
'YES!', $text );
97 'Test {{PAGEID}} Test',
99 return $rev->getPageId();
102 yield
'REVISIONID' => [
103 'Test {{REVISIONID}} Test',
105 return $rev->getId();
108 yield
'REVISIONUSER' => [
109 'Test {{REVISIONUSER}} Test',
111 return $rev->getUser()->getName();
114 yield
'REVISIONTIMESTAMP' => [
115 'Test {{REVISIONTIMESTAMP}} Test',
117 return $rev->getTimestamp();
126 $options = ParserOptions::newCanonical(
'canonical' );
128 $rev = $page->getRevision()->getRevisionRecord();
136 $expected = strval( $callback(
$rev ) );
137 $output = $work->getParserOutput();
139 $this->assertContains( $expected,
$output->getText() );
143 $options = ParserOptions::newCanonical(
'canonical' );
147 $this->assertFalse( $work->execute() );
151 $options = ParserOptions::newCanonical(
'canonical' );
153 $rev1 = $page->getRevision()->getRevisionRecord();
160 $fakeRev->setId( $rev1->getId() );
161 $fakeRev->setPageId( $page->getId() );
162 $fakeRev->setContent( SlotRecord::MAIN,
new WikitextContent(
'SECRET' ) );
163 $fakeRev->setVisibility( RevisionRecord::DELETED_TEXT );
166 $this->assertFalse( $work->execute() );
169 RevisionRecord::RAW );
170 $this->assertNotFalse( $work->execute() );
173 $fakeRev->setId( $rev2->getId() );
175 $this->assertNotFalse( $work->execute() );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
PoolWorkArticleView Database.
makeRevision(WikiPage $page, $text)
testDoWorkDeletedContent()
testMagicWords( $wikitext, $callback)
provideMagicWords
testDoWorkWithExplicitRevision()
Class representing a MediaWiki article and history.
newPageUpdater(User $user, RevisionSlotsUpdate $forUpdate=null)
Returns a PageUpdater for creating new revisions on this page (or creating the page).
Content object for wiki text pages.
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
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
return true to allow those checks to and false if checking is done & $user
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
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
$page->newPageUpdater($user) $updater