6use InvalidArgumentException;
39 $title = Title::newFromText(
'Dummy' );
40 $title->resetArticleID( 17 );
43 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
47 if ( isset( $rowOverrides[
'rev_deleted'] ) ) {
48 $record->setVisibility( $rowOverrides[
'rev_deleted'] );
51 if ( isset( $rowOverrides[
'rev_id'] ) ) {
52 $record->setId( $rowOverrides[
'rev_id'] );
55 if ( isset( $rowOverrides[
'rev_page'] ) ) {
56 $record->setPageId( $rowOverrides[
'rev_page'] );
59 $record->setContent( SlotRecord::MAIN,
new TextContent(
'Lorem Ipsum' ) );
60 $record->setComment( $comment );
61 $record->setUser(
$user );
62 $record->setTimestamp(
'20101010000000' );
68 $title = Title::newFromText(
'Dummy' );
69 $title->resetArticleID( 17 );
89 $this->assertSame(
$title, $rec->getPageAsLinkTarget(),
'getPageAsLinkTarget' );
90 $this->assertSame( $wikiId, $rec->getWikiId(),
'getWikiId' );
94 $title = Title::newFromText(
'Dummy' );
95 $title->resetArticleID( 17 );
97 yield
'not a wiki id' => [
113 $this->setExpectedException( InvalidArgumentException::class );
119 $this->assertNull( $record->getId() );
120 $record->setId( 888 );
121 $this->assertSame( 888, $record->getId() );
127 $this->assertNull( $record->getUser() );
128 $record->setUser(
$user );
129 $this->assertSame(
$user, $record->getUser() );
134 $this->assertSame( 0, $record->getPageId() );
135 $record->setPageId( 999 );
136 $this->assertSame( 999, $record->getPageId() );
141 $this->assertNull( $record->getParentId() );
142 $record->setParentId( 100 );
143 $this->assertSame( 100, $record->getParentId() );
148 $this->setExpectedException( RevisionAccessException::class );
149 $this->assertNull( $record->getContent( SlotRecord::MAIN ) );
155 $record->setContent( SlotRecord::MAIN,
$content );
156 $this->assertSame(
$content, $record->getContent( SlotRecord::MAIN ) );
161 $this->assertFalse( $record->hasSlot( SlotRecord::MAIN ) );
163 $this->setExpectedException( RevisionAccessException::class );
164 $record->getSlot( SlotRecord::MAIN );
169 $slot = SlotRecord::newUnsaved(
173 $record->setSlot( $slot );
174 $this->assertTrue( $record->hasSlot( SlotRecord::MAIN ) );
175 $this->assertSame( $slot, $record->getSlot( SlotRecord::MAIN ) );
180 $this->assertFalse( $record->isMinor() );
181 $record->setMinorEdit(
true );
182 $this->assertSame(
true, $record->isMinor() );
187 $this->assertNull( $record->getTimestamp() );
188 $record->setTimestamp(
'20180101010101' );
189 $this->assertSame(
'20180101010101', $record->getTimestamp() );
194 $this->assertSame( 0, $record->getVisibility() );
195 $record->setVisibility( RevisionRecord::DELETED_USER );
196 $this->assertSame( RevisionRecord::DELETED_USER, $record->getVisibility() );
201 $this->assertSame(
'phoiac9h4m842xq45sp7s6u21eteeq1', $record->getSha1() );
202 $record->setSha1(
'someHash' );
203 $this->assertSame(
'someHash', $record->getSha1() );
208 $this->assertInstanceOf( MutableRevisionSlots::class, $record->getSlots() );
213 $this->assertSame( 0, $record->getSize() );
214 $record->setSize( 775 );
215 $this->assertSame( 775, $record->getSize() );
221 $this->assertNull( $record->getComment() );
222 $record->setComment( $comment );
223 $this->assertSame( $comment, $record->getComment() );
231 'slot_revision_id' =>
null,
232 'slot_content_id' => 1,
233 'content_address' =>
null,
235 'role_name' =>
'main',
236 'slot_origin' =>
null
243 'slot_revision_id' =>
null,
244 'slot_content_id' => 1,
245 'content_address' =>
'foo',
247 'role_name' =>
'aux',
253 $record->setSlot( $mainSlot );
254 $record->setSlot( $auxSlot );
256 $this->assertSame( [
'main' ], $record->getOriginalSlots()->getSlotRoles() );
257 $this->assertSame( $mainSlot, $record->getOriginalSlots()->getSlot( SlotRecord::MAIN ) );
259 $this->assertSame( [
'aux' ], $record->getInheritedSlots()->getSlotRoles() );
260 $this->assertSame( $auxSlot, $record->getInheritedSlots()->getSlot(
'aux' ) );
269 $record->inheritSlot( SlotRecord::newSaved( 7, 3,
'a', SlotRecord::newUnsaved(
'a', $a ) ) );
270 $record->inheritSlot( SlotRecord::newSaved( 7, 4,
'b', SlotRecord::newUnsaved(
'b', $b ) ) );
272 $record->removeSlot(
'b' );
274 $this->assertTrue( $record->hasSlot(
'a' ) );
275 $this->assertFalse( $record->hasSlot(
'b' ) );
286 $update->modifyContent(
'b', $x );
287 $update->modifyContent(
'c', $x );
288 $update->removeSlot(
'c' );
289 $update->removeSlot(
'd' );
292 $record->inheritSlot( SlotRecord::newSaved( 7, 3,
'a', SlotRecord::newUnsaved(
'a', $a ) ) );
293 $record->inheritSlot( SlotRecord::newSaved( 7, 4,
'b', SlotRecord::newUnsaved(
'b', $b ) ) );
294 $record->inheritSlot( SlotRecord::newSaved( 7, 5,
'c', SlotRecord::newUnsaved(
'c', $c ) ) );
296 $record->applyUpdate( $update );
298 $this->assertEquals( [
'b' ], array_keys( $record->getOriginalSlots()->getSlots() ) );
299 $this->assertEquals( $a, $record->getSlot(
'a' )->getContent() );
300 $this->assertEquals( $x, $record->getSlot(
'b' )->getContent() );
301 $this->assertFalse( $record->hasSlot(
'c' ) );
306 $title = $this->getMock( Title::class );
309 $user = $this->getMock( User::class );
312 $comment = $this->getMockBuilder( CommentStoreComment::class )
313 ->disableOriginalConstructor()
319 yield
'empty' => [
$rev ];
324 $rev->setComment( $comment );
325 yield
'no timestamp' => [
$rev ];
329 $rev->setComment( $comment );
330 $rev->setTimestamp(
'20101010000000' );
331 yield
'no content' => [
$rev ];
335 $rev->setComment( $comment );
336 $rev->setTimestamp(
'20101010000000' );
337 yield
'no user' => [
$rev ];
342 $rev->setTimestamp(
'20101010000000' );
343 yield
'no comment' => [
$rev ];
350 $this->assertFalse(
$rev->isReadyForInsertion() );
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.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Content object for wiki text pages.
namespace and then decline to actually register it file or subcat img or subcat $title
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 null
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))