6use PHPUnit\Framework\MockObject\MockObject;
20 return preg_replace(
'/<!--.*?-->/s',
'',
$output->getHTML() );
33 if ( is_string(
$title ) ) {
37 $page = WikiPage::factory(
$title );
41 foreach ( $revisionContents
as $key => $cont ) {
42 if ( is_string( $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();
69 $this->assertSame( $idA,
$article->getOldID() );
71 $this->assertSame( $idA,
$article->getRevIdFetched() );
75 $this->assertSame( 0,
$article->getOldID() );
77 $this->assertSame( $idB,
$article->getRevIdFetched() );
84 $this->assertSame( $idA,
$article->getOldID() );
86 $this->assertSame( $idA,
$article->getRevIdFetched() );
93 $this->assertSame( 0,
$article->getOldID() );
95 $this->assertSame( $idB,
$article->getRevIdFetched() );
99 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
107 $this->assertNotContains(
'id="mw-revision-info"', $this->
getHtml(
$output ) );
108 $this->assertNotContains(
'id="mw-revision-nav"', $this->
getHtml(
$output ) );
112 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
119 $cache = MediaWikiServices::getInstance()->getParserCache();
125 $this->assertContains(
'Cached Text', $this->
getHtml(
$output ) );
135 $redirectText =
'#REDIRECT [[' . $target->getPrefixedText() .
']]';
137 $page = $this->
getPage( __METHOD__, [ $redirectText ] );
143 $this->assertNotNull(
144 $article->getRedirectTarget()->getPrefixedDBkey()
147 $target->getPrefixedDBkey(),
148 $article->getRedirectTarget()->getPrefixedDBkey()
152 $this->assertContains(
'class="redirectText"', $this->
getHtml(
$output ) );
153 $this->assertContains(
154 '>' . htmlspecialchars( $target->getPrefixedText() ) .
'<',
160 $dummy = $this->
getPage( __METHOD__, [
'Dummy' ] );
161 $dummyRev = $dummy->getRevision()->getRevisionRecord();
162 $title = $dummy->getTitle();
165 $mockHandler = $this->getMockBuilder( ContentHandler::class )
168 'isParserCacheSupported',
170 'unserializeContent',
174 ->setConstructorArgs( [
'NotText', [
'application/frobnitz' ] ] )
177 $mockHandler->method(
'isParserCacheSupported' )
178 ->willReturn(
false );
181 'ContentHandlerForModelID',
188 $content = $this->getMock( Content::class );
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() );
200 $rev->setUser( $dummyRev->getUser() );
201 $rev->setComment( $dummyRev->getComment() );
202 $rev->setTimestamp( $dummyRev->getTimestamp() );
209 $page = $this->getMockBuilder( WikiPage::class )
210 ->setMethods( [
'getRevision',
'getLatest' ] )
211 ->setConstructorArgs( [
$title ] )
214 $page->method(
'getRevision' )
215 ->willReturn(
$rev );
216 $page->method(
'getLatest' )
217 ->willReturn(
$rev->getId() );
224 $this->assertContains(
'Structured Output', $this->
getHtml(
$output ) );
230 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
231 $idA = $revisions[1]->getId();
239 $this->assertContains(
'id="mw-revision-info"',
$output->getSubtitle() );
240 $this->assertContains(
'id="mw-revision-nav"',
$output->getSubtitle() );
242 $this->assertNotContains(
'id="revision-info-current"',
$output->getSubtitle() );
248 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
249 $idB = $revisions[2]->getId();
257 $this->assertContains(
'id="mw-revision-info-current"',
$output->getSubtitle() );
258 $this->assertContains(
'id="mw-revision-nav"',
$output->getSubtitle() );
263 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ], $revisions );
264 $badId = $revisions[1]->getId() + 100;
271 $this->assertContains(
'missing-revision: ' . $badId, $this->
getHtml(
$output ) );
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",
294 $this->assertContains(
'(rev-deleted-text-permission)', $this->
getHtml(
$output ) );
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 );
322 $this->assertContains(
'(rev-deleted-text-view)', $this->
getHtml(
$output ) );
329 $page = $this->
getPage( __METHOD__ );
336 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
340 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
341 $page->doDeleteArticle(
'Test' );
348 $this->assertContains(
'moveddeleted', $this->
getHtml(
$output ) );
349 $this->assertContains(
'logentry-delete-delete', $this->
getHtml(
$output ) );
350 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
365 $this->assertContains(
366 wfMessage(
'mainpage' )->inContentLanguage()->parse(),
369 $this->assertNotContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
374 $user->addToDatabase();
385 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
386 $this->assertNotContains(
'(userpage-userdoesnotexist-view)', $this->
getHtml(
$output ) );
401 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
402 $this->assertContains(
'(userpage-userdoesnotexist-view:', $this->
getHtml(
$output ) );
406 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
414 $this->assertSame(
$article, $articlePage,
'$articlePage' );
417 $outputDone->setTitleText(
'Hook Title' );
419 $articlePage->
getContext()->getOutput()->addParserOutput( $outputDone );
428 $this->assertSame(
'Hook Title',
$output->getPageTitle() );
432 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
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)'
463 $this->assertNotContains(
'Test A', $this->
getHtml( $output ) );
464 $this->assertContains(
'Hook Text', $this->
getHtml( $output ) );
468 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
477 $useParserCache =
false;
482 'ArticleRevisionViewCustom',
485 $this->assertSame( $page->getTitle(),
$title,
'$title' );
486 $this->assertSame(
'Test A',
$content->getText(),
'$content' );
488 $output->addHTML(
'Hook Text' );
496 $this->assertNotContains(
'Test A', $this->
getHtml( $output ) );
497 $this->assertContains(
'Hook Text', $this->
getHtml( $output ) );
501 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
510 $useParserCache =
false;
515 'ArticleAfterFetchContentObject',
517 $this->assertSame(
$article, $articlePage,
'$articlePage' );
518 $this->assertSame(
'Test A',
$content->getText(),
'$content' );
525 'ArticleAfterFetchContentObject hook'
526 .
' (used in hook-ArticleAfterFetchContentObject-closure)'
537 $page = $this->
getPage( __METHOD__ );
543 'ShowMissingArticle',
545 $this->assertSame(
$article, $articlePage,
'$articlePage' );
547 $articlePage->
getContext()->getOutput()->addHTML(
'Hook Text' );
554 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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.
getContext()
Gets the context this Article is executed in.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
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...
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 document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
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))