6use InvalidArgumentException;
31 $title = Title::newFromText(
'Dummy' );
32 $title->resetArticleID( 17 );
35 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
37 $main = SlotRecord::newUnsaved( SlotRecord::MAIN,
new TextContent(
'Lorem Ipsum' ) );
38 $aux = SlotRecord::newUnsaved(
'aux',
new TextContent(
'Frumious Bandersnatch' ) );
43 'rev_page' => strval(
$title->getArticleID() ),
44 'rev_timestamp' =>
'20200101000000',
46 'rev_minor_edit' => 0,
47 'rev_parent_id' =>
'5',
48 'rev_len' => $slots->computeSize(),
49 'rev_sha1' => $slots->computeSha1(),
50 'page_latest' =>
'18',
53 $row = array_merge( $row, $rowOverrides );
59 $title = Title::newFromText(
'Dummy' );
60 $title->resetArticleID( 17 );
63 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
65 $main = SlotRecord::newUnsaved( SlotRecord::MAIN,
new TextContent(
'Lorem Ipsum' ) );
66 $aux = SlotRecord::newUnsaved(
'aux',
new TextContent(
'Frumious Bandersnatch' ) );
71 'rev_page' => strval(
$title->getArticleID() ),
72 'rev_timestamp' =>
'20200101000000',
74 'rev_minor_edit' => 0,
75 'rev_parent_id' =>
'5',
76 'rev_len' => $slots->computeSize(),
77 'rev_sha1' => $slots->computeSha1(),
78 'page_latest' =>
'18',
92 $row[
'rev_minor_edit'] =
'1';
93 $row[
'rev_deleted'] = strval( RevisionRecord::DELETED_USER );
95 yield
'minor deleted' => [
104 $row[
'page_latest'] = $row[
'rev_id'];
115 unset( $row[
'rev_parent'] );
117 yield
'no parent' => [
126 $row[
'rev_len'] =
null;
127 $row[
'rev_sha1'] =
'';
129 yield
'rev_len is null, rev_sha1 is ""' => [
138 yield
'no length, no hash' => [
139 Title::newFromText(
'DummyDoesNotExist' ),
167 $this->assertSame(
$title, $rec->getPageAsLinkTarget(),
'getPageAsLinkTarget' );
168 $this->assertSame(
$user, $rec->getUser( RevisionRecord::RAW ),
'getUser' );
169 $this->assertSame( $comment, $rec->getComment(),
'getComment' );
171 $this->assertSame( $slots, $rec->
getSlots(),
'getSlots' );
172 $this->assertSame( $slots->
getSlotRoles(), $rec->getSlotRoles(),
'getSlotRoles' );
173 $this->assertSame( $slots->
getSlots(), $rec->getSlots()->getSlots(),
'getSlots' );
174 $this->assertSame( $wikiId, $rec->getWikiId(),
'getWikiId' );
176 $this->assertSame( (
int)$row->rev_id, $rec->getId(),
'getId' );
177 $this->assertSame( (
int)$row->rev_page, $rec->getPageId(),
'getId' );
178 $this->assertSame( $row->rev_timestamp, $rec->getTimestamp(),
'getTimestamp' );
179 $this->assertSame( (
int)$row->rev_deleted, $rec->getVisibility(),
'getVisibility' );
180 $this->assertSame( (
bool)$row->rev_minor_edit, $rec->isMinor(),
'getIsMinor' );
182 if ( isset( $row->rev_parent_id ) ) {
183 $this->assertSame( (
int)$row->rev_parent_id, $rec->getParentId(),
'getParentId' );
185 $this->assertSame( 0, $rec->getParentId(),
'getParentId' );
188 if ( isset( $row->rev_len ) ) {
189 $this->assertSame( (
int)$row->rev_len, $rec->getSize(),
'getSize' );
191 $this->assertSame( $slots->
computeSize(), $rec->getSize(),
'getSize' );
194 if ( !empty( $row->rev_sha1 ) ) {
195 $this->assertSame( $row->rev_sha1, $rec->getSha1(),
'getSha1' );
197 $this->assertSame( $slots->
computeSha1(), $rec->getSha1(),
'getSha1' );
200 if ( isset( $row->page_latest ) ) {
202 (
int)$row->rev_id === (
int)$row->page_latest,
216 $title = Title::newFromText(
'Dummy' );
217 $title->resetArticleID( 17 );
221 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
223 $main = SlotRecord::newUnsaved( SlotRecord::MAIN,
new TextContent(
'Lorem Ipsum' ) );
224 $aux = SlotRecord::newUnsaved(
'aux',
new TextContent(
'Frumious Bandersnatch' ) );
229 'rev_page' => strval(
$title->getArticleID() ),
230 'rev_timestamp' =>
'20200101000000',
232 'rev_minor_edit' => 0,
233 'rev_parent_id' =>
'5',
234 'rev_len' => $slots->computeSize(),
235 'rev_sha1' => $slots->computeSha1(),
236 'page_latest' =>
'18',
239 yield
'not a row' => [
249 $row[
'rev_timestamp'] =
'kittens';
251 yield
'bad timestamp' => [
260 $row[
'rev_page'] = 99;
262 yield
'page ID mismatch' => [
272 yield
'bad wiki' => [
300 $this->setExpectedException( InvalidArgumentException::class );
327 $this->assertSame( $current,
$rev->isCurrent(),
'isCurrent()' );
343 'rev_deleted' => $visibility,
350 $this->assertNotNull(
$rev->getSlot( SlotRecord::MAIN, RevisionRecord::RAW ),
'raw can' );
351 $this->assertNotNull(
$rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_PUBLIC ),
354 $this->assertNotNull(
355 $rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_THIS_USER,
$user ),
359 $rev->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )->getContent();
362 $rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_PUBLIC )->getContent();
363 $rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_THIS_USER,
$user )->getContent();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Content object implementation for representing flat text.
Represents a title within MediaWiki.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
namespace and then decline to actually register it file or subcat img or subcat $title
return true to allow those checks to and false if checking is done & $user
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
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))