37 $page = WikiPage::factory( $title );
41 foreach ( $revisionContents as $key => $cont ) {
46 $u = $page->newPageUpdater( $user );
47 $u->setContent( SlotRecord::MAIN, $cont );
48 $rev = $u->saveRevision( CommentStoreComment::newUnsavedComment(
'Rev ' . $key ) );
50 $revisions[ $key ] =
$rev;
62 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
64 $idA = $revisions[1]->getId();
65 $idB = $revisions[2]->getId();
99 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
102 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
112 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
117 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
119 $cache = MediaWikiServices::getInstance()->getParserCache();
135 $redirectText =
'#REDIRECT [[' . $target->getPrefixedText() .
']]';
137 $page = $this->
getPage( __METHOD__, [ $redirectText ] );
140 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
144 $article->getRedirectTarget()->getPrefixedDBkey()
147 $target->getPrefixedDBkey(),
148 $article->getRedirectTarget()->getPrefixedDBkey()
160 $dummy = $this->
getPage( __METHOD__, [
'Dummy' ] );
161 $dummyRev = $dummy->getRevision()->getRevisionRecord();
162 $title = $dummy->getTitle();
168 'isParserCacheSupported',
170 'unserializeContent',
174 ->setConstructorArgs( [
'NotText', [
'application/frobnitz' ] ] )
177 $mockHandler->method(
'isParserCacheSupported' )
178 ->willReturn(
false );
181 'ContentHandlerForModelID',
182 function ( $id, &
$handler ) use ( $mockHandler ) {
189 $content->method(
'getParserOutput' )
190 ->willReturn(
new ParserOutput(
'Structured Output' ) );
192 ->willReturn(
'NotText' );
193 $content->expects( $this->never() )->method(
'getNativeData' );
198 $rev->setId( $dummyRev->getId() );
199 $rev->setPageId( $title->getArticleID() );
200 $rev->setUser( $dummyRev->getUser() );
201 $rev->setComment( $dummyRev->getComment() );
202 $rev->setTimestamp( $dummyRev->getTimestamp() );
210 ->setMethods( [
'getRevision',
'getLatest' ] )
211 ->setConstructorArgs( [ $title ] )
214 $page->method(
'getRevision' )
215 ->willReturn(
$rev );
216 $page->method(
'getLatest' )
217 ->willReturn(
$rev->getId() );
220 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
230 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
231 $idA = $revisions[1]->getId();
234 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
248 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
249 $idB = $revisions[2]->getId();
252 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
263 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ], $revisions );
264 $badId = $revisions[1]->getId() + 100;
267 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
278 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
279 $idA = $revisions[1]->getId();
282 RequestContext::getMain(), $page->getTitle(), [ $idA ]
284 $revDelList->setVisibility( [
285 'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
286 'comment' =>
"Testing",
290 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
302 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
303 $idA = $revisions[1]->getId();
306 RequestContext::getMain(), $page->getTitle(), [ $idA ]
308 $revDelList->setVisibility( [
309 'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
310 'comment' =>
"Testing",
316 $context->getOutput()->setTitle( $page->getTitle() );
317 $context->getRequest()->setVal(
'unhide', 1 );
329 $page = $this->
getPage( __METHOD__ );
332 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
340 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
341 $page->doDeleteArticle(
'Test' );
344 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
357 $title = Title::makeTitle( NS_MEDIAWIKI,
'Mainpage' );
358 $page = $this->
getPage( $title );
361 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
366 wfMessage(
'mainpage' )->inContentLanguage()->parse(),
374 $user->addToDatabase();
376 $title = Title::makeTitle( NS_USER, $user->getName() );
378 $page = $this->
getPage( $title );
381 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
392 $title = Title::makeTitle( NS_USER, $user->getName() );
394 $page = $this->
getPage( $title );
397 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
406 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
409 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
413 function (
Article $articlePage, &$outputDone, &$useParserCache ) use (
$article ) {
417 $outputDone->setTitleText(
'Hook Title' );
419 $articlePage->getContext()->getOutput()->addParserOutput( $outputDone );
432 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
435 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
440 function (
Article $articlePage, &$outputDone, &$useParserCache ) use (
$article ) {
441 $useParserCache =
false;
446 'ArticleContentViewCustom',
448 $this->
assertSame( $page->getTitle(), $title,
'$title' );
449 $this->
assertSame(
'Test A', $content->getText(),
'$content' );
451 $output->addHTML(
'Hook Text' );
457 'ArticleContentViewCustom hook (used in hook-ArticleContentViewCustom-closure)'
462 $output =
$article->getContext()->getOutput();
468 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
471 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
476 function (
Article $articlePage, &$outputDone, &$useParserCache ) use (
$article ) {
477 $useParserCache =
false;
482 'ArticleRevisionViewCustom',
485 $this->
assertSame( $page->getTitle(), $title,
'$title' );
488 $output->
addHTML(
'Hook Text' );
501 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
504 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
509 function (
Article $articlePage, &$outputDone, &$useParserCache ) use (
$article ) {
510 $useParserCache =
false;
515 'ArticleAfterFetchContentObject',
518 $this->
assertSame(
'Test A', $content->getText(),
'$content' );
525 'ArticleAfterFetchContentObject hook'
526 .
' (used in hook-ArticleAfterFetchContentObject-closure)'
537 $page = $this->
getPage( __METHOD__ );
540 $article->getContext()->getOutput()->setTitle( $page->getTitle() );
543 'ShowMissingArticle',
547 $articlePage->getContext()->getOutput()->addHTML(
'Hook Text' );
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
testArticleViewHeaderHook()
testViewOfCurrentRevision()
testViewOfMissingRevision()
getPage( $title, array $revisionContents=[], array &$revisions=[])
testShowMissingArticleHook()
testArticleContentViewCustomHook()
testViewMissingUserPage()
testGetOldId()
Article::getOldId() Article::getRevIdFetched()
testArticleRevisionViewCustomHook()
getHtml(OutputPage $output)
testViewUserPageOfNonexistingUser()
testViewOfDeletedRevision()
testUnhiddenViewOfDeletedRevision()
testArticleAfterFetchContentObjectHook()
testViewRedirect()
Article::getRedirectTarget()
Class for viewing MediaWiki article and history.
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
An IContextSource implementation which will inherit context from another source but allow individual ...
WebRequest clone which takes values from a provided array.
This class should be covered by a general architecture document which does not exist as of January 20...
addHTML( $text)
Append $text to the body HTML.
Group all the pieces relevant to the context of a request into one instance.
List for revision table items.
Represents a title within MediaWiki.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file & $article
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
Base interface for content objects.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))