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' );
194 ->willReturn( [ (
object)[
'x' =>
'stuff' ] ] );
199 $rev->setId( $dummyRev->getId() );
201 $rev->setUser( $dummyRev->getUser() );
202 $rev->setComment( $dummyRev->getComment() );
203 $rev->setTimestamp( $dummyRev->getTimestamp() );
210 $page = $this->getMockBuilder( WikiPage::class )
211 ->setMethods( [
'getRevision',
'getLatest' ] )
212 ->setConstructorArgs( [
$title ] )
215 $page->method(
'getRevision' )
216 ->willReturn(
$rev );
217 $page->method(
'getLatest' )
218 ->willReturn(
$rev->getId() );
225 $this->assertContains(
'Structured Output', $this->
getHtml(
$output ) );
231 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
232 $idA = $revisions[1]->getId();
240 $this->assertContains(
'id="mw-revision-info"',
$output->getSubtitle() );
241 $this->assertContains(
'id="mw-revision-nav"',
$output->getSubtitle() );
243 $this->assertNotContains(
'id="revision-info-current"',
$output->getSubtitle() );
249 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
250 $idB = $revisions[2]->getId();
258 $this->assertContains(
'id="mw-revision-info-current"',
$output->getSubtitle() );
259 $this->assertContains(
'id="mw-revision-nav"',
$output->getSubtitle() );
264 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ], $revisions );
265 $badId = $revisions[1]->getId() + 100;
272 $this->assertContains(
'missing-revision: ' . $badId, $this->
getHtml(
$output ) );
279 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
280 $idA = $revisions[1]->getId();
283 RequestContext::getMain(), $page->getTitle(), [ $idA ]
285 $revDelList->setVisibility( [
286 'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
287 'comment' =>
"Testing",
295 $this->assertContains(
'(rev-deleted-text-permission)', $this->
getHtml(
$output ) );
303 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ], $revisions );
304 $idA = $revisions[1]->getId();
307 RequestContext::getMain(), $page->getTitle(), [ $idA ]
309 $revDelList->setVisibility( [
310 'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
311 'comment' =>
"Testing",
317 $context->getOutput()->setTitle( $page->getTitle() );
318 $context->getRequest()->setVal(
'unhide', 1 );
323 $this->assertContains(
'(rev-deleted-text-view)', $this->
getHtml(
$output ) );
330 $page = $this->
getPage( __METHOD__ );
337 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
341 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A', 2 =>
'Test B' ] );
342 $page->doDeleteArticle(
'Test' );
349 $this->assertContains(
'moveddeleted', $this->
getHtml(
$output ) );
350 $this->assertContains(
'logentry-delete-delete', $this->
getHtml(
$output ) );
351 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
366 $this->assertContains(
367 wfMessage(
'mainpage' )->inContentLanguage()->parse(),
370 $this->assertNotContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
375 $user->addToDatabase();
386 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
387 $this->assertNotContains(
'(userpage-userdoesnotexist-view)', $this->
getHtml(
$output ) );
402 $this->assertContains(
'(noarticletextanon)', $this->
getHtml(
$output ) );
403 $this->assertContains(
'(userpage-userdoesnotexist-view:', $this->
getHtml(
$output ) );
407 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
415 $this->assertSame(
$article, $articlePage,
'$articlePage' );
418 $outputDone->setTitleText(
'Hook Title' );
420 $articlePage->
getContext()->getOutput()->addParserOutput( $outputDone );
429 $this->assertSame(
'Hook Title',
$output->getPageTitle() );
433 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
442 $useParserCache =
false;
447 'ArticleContentViewCustom',
449 $this->assertSame( $page->getTitle(),
$title,
'$title' );
450 $this->assertSame(
'Test A',
$content->getNativeData(),
'$content' );
452 $output->addHTML(
'Hook Text' );
458 'ArticleContentViewCustom hook (used in hook-ArticleContentViewCustom-closure)'
464 $this->assertNotContains(
'Test A', $this->
getHtml( $output ) );
465 $this->assertContains(
'Hook Text', $this->
getHtml( $output ) );
469 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
478 $useParserCache =
false;
483 'ArticleRevisionViewCustom',
487 $this->assertSame( $page->getTitle(),
$title,
'$title' );
488 $this->assertSame(
'Test A',
$content->getNativeData(),
'$content' );
490 $output->addHTML(
'Hook Text' );
498 $this->assertNotContains(
'Test A', $this->
getHtml( $output ) );
499 $this->assertContains(
'Hook Text', $this->
getHtml( $output ) );
503 $page = $this->
getPage( __METHOD__, [ 1 =>
'Test A' ] );
512 $useParserCache =
false;
517 'ArticleAfterFetchContentObject',
519 $this->assertSame(
$article, $articlePage,
'$articlePage' );
520 $this->assertSame(
'Test A',
$content->getNativeData(),
'$content' );
527 'ArticleAfterFetchContentObject hook'
528 .
' (used in hook-ArticleAfterFetchContentObject-closure)'
539 $page = $this->
getPage( __METHOD__ );
545 'ShowMissingArticle',
547 $this->assertSame(
$article, $articlePage,
'$articlePage' );
549 $articlePage->
getContext()->getOutput()->addHTML(
'Hook Text' );
556 $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
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
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
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
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))