8use InvalidArgumentException;
39 $this->tablesUsed[] =
'archive';
40 $this->tablesUsed[] =
'page';
41 $this->tablesUsed[] =
'revision';
42 $this->tablesUsed[] =
'comment';
49 $lb = $this->getMockBuilder( LoadBalancer::class )
50 ->setMethods( [
'reallyOpenConnection' ] )
51 ->setConstructorArgs( [ [
'servers' => [ $server ] ] ] )
54 $lb->method(
'reallyOpenConnection' )->willReturnCallback(
55 function ( array $server, $dbNameOverride ) {
67 $db = $this->getMockBuilder( DatabaseSqlite::class )
68 ->setMethods( [
'select',
'doQuery',
'open',
'closeConnection',
'isOpen' ] )
69 ->setConstructorArgs( [
$params ] )
73 $db->method(
'isOpen' )->willReturn(
true );
79 yield [
false,
'test',
'' ];
80 yield [
'test',
'test',
'' ];
82 yield [
false,
'test',
'foo_' ];
83 yield [
'test-foo_',
'test',
'foo_' ];
85 yield [
false,
'dash-test',
'' ];
86 yield [
'dash-test',
'dash-test',
'' ];
88 yield [
false,
'underscore_test',
'foo_' ];
89 yield [
'underscore_test-foo_',
'underscore_test',
'foo_' ];
99 'wgDBname' => $dbName,
100 'wgDBprefix' => $dbPrefix,
107 'dbDirectory' =>
'*dummy*',
109 'password' =>
'test',
118 'connLogger' =>
new \Psr\Log\NullLogger(),
119 'queryLogger' =>
new \Psr\Log\NullLogger(),
120 'errorLogger' =>
function () {
122 'deprecationLogger' =>
function () {
126 'tablePrefix' => $dbPrefix,
131 $blobStore = $this->getMockBuilder( SqlBlobStore::class )
132 ->disableOriginalConstructor()
144 $count = $store->countRevisionsByPageId(
$db, 0 );
148 $this->assertSame( 0, $count );
152 $this->assertEquals( $l1->getDBkey(), $l2->getDBkey() );
153 $this->assertEquals( $l1->getNamespace(), $l2->getNamespace() );
154 $this->assertEquals( $l1->getFragment(), $l2->getFragment() );
155 $this->assertEquals( $l1->getInterwiki(), $l2->getInterwiki() );
159 $this->assertEquals( $r1->getUser()->getName(), $r2->getUser()->getName() );
160 $this->assertEquals( $r1->getUser()->getId(), $r2->getUser()->getId() );
161 $this->assertEquals( $r1->getComment(), $r2->getComment() );
162 $this->assertEquals( $r1->getPageAsLinkTarget(), $r2->getPageAsLinkTarget() );
163 $this->assertEquals( $r1->getTimestamp(), $r2->getTimestamp() );
164 $this->assertEquals( $r1->getVisibility(), $r2->getVisibility() );
165 $this->assertEquals( $r1->getSha1(), $r2->getSha1() );
166 $this->assertEquals( $r1->getParentId(), $r2->getParentId() );
167 $this->assertEquals( $r1->getSize(), $r2->getSize() );
168 $this->assertEquals( $r1->getPageId(), $r2->getPageId() );
169 $this->assertEquals( $r1->getSlotRoles(), $r2->getSlotRoles() );
170 $this->assertEquals( $r1->getWikiId(), $r2->getWikiId() );
171 $this->assertEquals( $r1->isMinor(), $r2->isMinor() );
172 foreach ( $r1->getSlotRoles() as $role ) {
174 $this->assertTrue( $r1->getContent( $role )->equals( $r2->getContent( $role ) ) );
177 RevisionRecord::DELETED_TEXT,
178 RevisionRecord::DELETED_COMMENT,
179 RevisionRecord::DELETED_USER,
180 RevisionRecord::DELETED_RESTRICTED,
182 $this->assertEquals( $r1->isDeleted( $field ), $r2->isDeleted( $field ) );
187 $this->assertSame( $s1->getRole(), $s2->getRole() );
188 $this->assertSame( $s1->getModel(), $s2->getModel() );
189 $this->assertSame( $s1->getFormat(), $s2->getFormat() );
190 $this->assertSame( $s1->getSha1(), $s2->getSha1() );
191 $this->assertSame( $s1->getSize(), $s2->getSize() );
192 $this->assertTrue( $s1->getContent()->equals( $s2->getContent() ) );
194 $s1->hasRevision() ? $this->assertSame( $s1->getRevision(), $s2->getRevision() ) :
null;
195 $s1->hasAddress() ? $this->assertSame( $s1->hasAddress(), $s2->hasAddress() ) :
null;
217 if ( isset( $details[
'user'] ) && $details[
'user'] ===
true ) {
218 $details[
'user'] = $this->
getTestUser()->getUser();
220 if ( isset( $details[
'page'] ) && $details[
'page'] ===
true ) {
221 $details[
'page'] = $page->getId();
223 if ( isset( $details[
'parent'] ) && $details[
'parent'] ===
true ) {
224 $details[
'parent'] = $page->getLatest();
229 isset( $details[
'slot'] ) ?
$rev->setSlot( $details[
'slot'] ) :
null;
230 isset( $details[
'parent'] ) ?
$rev->setParentId( $details[
'parent'] ) :
null;
231 isset( $details[
'page'] ) ?
$rev->setPageId( $details[
'page'] ) :
null;
232 isset( $details[
'size'] ) ?
$rev->setSize( $details[
'size'] ) :
null;
233 isset( $details[
'sha1'] ) ?
$rev->setSha1( $details[
'sha1'] ) :
null;
234 isset( $details[
'comment'] ) ?
$rev->setComment( $details[
'comment'] ) :
null;
235 isset( $details[
'timestamp'] ) ?
$rev->setTimestamp( $details[
'timestamp'] ) :
null;
236 isset( $details[
'minor'] ) ?
$rev->setMinorEdit( $details[
'minor'] ) :
null;
237 isset( $details[
'user'] ) ?
$rev->setUser( $details[
'user'] ) :
null;
238 isset( $details[
'visibility'] ) ?
$rev->setVisibility( $details[
'visibility'] ) :
null;
239 isset( $details[
'id'] ) ?
$rev->setId( $details[
'id'] ) :
null;
245 return CommentStoreComment::newUnsavedComment( __METHOD__ .
'.' . rand( 0, 1000 ) );
249 yield
'Bare minimum revision insertion' => [
250 Title::newFromText(
'UTPage' ),
252 'slot' => SlotRecord::newUnsaved(
'main',
new WikitextContent(
'Chicken' ) ),
255 'timestamp' =>
'20171117010101',
259 yield
'Detailed revision insertion' => [
260 Title::newFromText(
'UTPage' ),
262 'slot' => SlotRecord::newUnsaved(
'main',
new WikitextContent(
'Chicken' ) ),
266 'timestamp' =>
'20171117010101',
269 'visibility' => RevisionRecord::DELETED_RESTRICTED,
293 $title = Title::newFromText(
'UTPage' );
295 'slot' => SlotRecord::newUnsaved(
'main',
new WikitextContent(
'Chicken' ) ),
298 'timestamp' =>
'20171117010101',
311 $revDetails[
'slot'] = SlotRecord::newInherited( $firstReturn->getSlot(
'main' ) );
319 $firstReturn->getSlot(
'main' )->getAddress(),
320 $secondReturn->getSlot(
'main' )->getAddress()
323 $this->assertNotSame(
324 $firstReturn->getId(),
325 $secondReturn->getId()
331 Title::newFromText(
'UTPage' ),
334 'timestamp' =>
'20171117010101',
337 new InvalidArgumentException(
'At least one slot needs to be defined!' )
339 yield
'slot that is not main slot' => [
340 Title::newFromText(
'UTPage' ),
342 'slot' => SlotRecord::newUnsaved(
'lalala',
new WikitextContent(
'Chicken' ) ),
344 'timestamp' =>
'20171117010101',
347 new InvalidArgumentException(
'Only the main slot is supported for now!' )
349 yield
'no timestamp' => [
350 Title::newFromText(
'UTPage' ),
352 'slot' => SlotRecord::newUnsaved(
'main',
new WikitextContent(
'Chicken' ) ),
358 yield
'no comment' => [
359 Title::newFromText(
'UTPage' ),
361 'slot' => SlotRecord::newUnsaved(
'main',
new WikitextContent(
'Chicken' ) ),
362 'timestamp' =>
'20171117010101',
368 Title::newFromText(
'UTPage' ),
370 'slot' => SlotRecord::newUnsaved(
'main',
new WikitextContent(
'Chicken' ) ),
372 'timestamp' =>
'20171117010101',
384 array $revDetails = [],
385 Exception $exception ) {
390 $this->setExpectedException(
391 get_class( $exception ),
392 $exception->getMessage(),
393 $exception->getCode()
400 Title::newFromText(
'UTPage' ),
401 CommentStoreComment::newUnsavedComment( __METHOD__ .
' comment1' ),
405 Title::newFromText(
'UTPage' ),
406 CommentStoreComment::newUnsavedComment( __METHOD__ .
' comment2', [
'a' => 1 ] ),
419 $parent = $store->getRevisionByTitle( $title );
420 $record = $store->newNullRevision(
428 $this->assertEquals( $title->getNamespace(), $record->getPageAsLinkTarget()->getNamespace() );
429 $this->assertEquals( $title->getDBkey(), $record->getPageAsLinkTarget()->getDBkey() );
430 $this->assertEquals( $comment, $record->getComment() );
431 $this->assertEquals( $minor, $record->isMinor() );
432 $this->assertEquals( $user->getName(), $record->getUser()->getName() );
433 $this->assertEquals( $parent->getId(), $record->getParentId() );
435 $parentSlot = $parent->getSlot(
'main' );
436 $slot = $record->getSlot(
'main' );
438 $this->assertTrue( $slot->isInherited(),
'isInherited' );
439 $this->assertSame( $parentSlot->getOrigin(), $slot->getOrigin(),
'getOrigin' );
440 $this->assertSame( $parentSlot->getAddress(), $slot->getAddress(),
'getAddress' );
448 $record = $store->newNullRevision(
450 Title::newFromText( __METHOD__ .
'.iDontExist!' ),
451 CommentStoreComment::newUnsavedComment( __METHOD__ .
' comment' ),
455 $this->assertNull( $record );
468 $revisionRecord = $store->getRevisionById(
$rev->getId() );
469 $result = $store->getRcIdIfUnpatrolled( $revisionRecord );
471 $this->assertGreaterThan( 0, $result );
473 $page->getRevision()->getRecentChange()->getAttribute(
'rc_id' ),
485 $status = $page->doEditContent(
496 $revisionRecord = $store->getRevisionById(
$rev->getId() );
497 $result = $store->getRcIdIfUnpatrolled( $revisionRecord );
499 $this->assertSame( 0, $result );
508 $status = $page->doEditContent( $content, __METHOD__ );
513 $revRecord = $store->getRevisionById(
$rev->getId() );
514 $recentChange = $store->getRecentChange( $revRecord );
516 $this->assertEquals(
$rev->getId(), $recentChange->getAttribute(
'rc_this_oldid' ) );
517 $this->assertEquals(
$rev->getRecentChange(), $recentChange );
526 $status = $page->doEditContent( $content, __METHOD__ );
531 $revRecord = $store->getRevisionById(
$rev->getId() );
533 $this->assertSame(
$rev->getId(), $revRecord->getId() );
534 $this->assertTrue( $revRecord->getSlot(
'main' )->getContent()->equals( $content ) );
535 $this->assertSame( __METHOD__, $revRecord->getComment()->text );
544 $status = $page->doEditContent( $content, __METHOD__ );
549 $revRecord = $store->getRevisionByTitle( $page->getTitle() );
551 $this->assertSame(
$rev->getId(), $revRecord->getId() );
552 $this->assertTrue( $revRecord->getSlot(
'main' )->getContent()->equals( $content ) );
553 $this->assertSame( __METHOD__, $revRecord->getComment()->text );
562 $status = $page->doEditContent( $content, __METHOD__ );
567 $revRecord = $store->getRevisionByPageId( $page->getId() );
569 $this->assertSame(
$rev->getId(), $revRecord->getId() );
570 $this->assertTrue( $revRecord->getSlot(
'main' )->getContent()->equals( $content ) );
571 $this->assertSame( __METHOD__, $revRecord->getComment()->text );
584 $status = $page->doEditContent( $content, __METHOD__ );
589 $revRecord = $store->getRevisionByTimestamp(
594 $this->assertSame(
$rev->getId(), $revRecord->getId() );
595 $this->assertTrue( $revRecord->getSlot(
'main' )->getContent()->equals( $content ) );
596 $this->assertSame( __METHOD__, $revRecord->getComment()->text );
606 'rev_timestamp' => (
string)
$rev->getTimestamp(),
607 'rev_user_text' => (
string)
$rev->getUserText(),
609 'rev_minor_edit' =>
$rev->isMinor() ?
'1' :
'0',
610 'rev_deleted' => (
string)
$rev->getVisibility(),
612 'rev_parent_id' => (
string)
$rev->getParentId(),
614 'rev_comment_text' =>
$rev->getComment(),
615 'rev_comment_data' =>
null,
616 'rev_comment_cid' =>
null,
617 'rev_content_format' =>
$rev->getContentFormat(),
618 'rev_content_model' =>
$rev->getContentModel(),
619 'page_namespace' => (
string)$page->getTitle()->getNamespace(),
620 'page_title' => $page->getTitle()->getDBkey(),
621 'page_id' => (
string)$page->getId(),
622 'page_latest' => (
string)$page->getLatest(),
623 'page_is_redirect' => $page->isRedirect() ?
'1' :
'0',
624 'page_len' => (
string)$page->getContent()->getSize(),
633 $this->assertSame(
$rev->getId(), $record->getId() );
634 $this->assertSame(
$rev->getPage(), $record->getPageId() );
635 $this->assertSame(
$rev->getTimestamp(), $record->getTimestamp() );
636 $this->assertSame(
$rev->getUserText(), $record->getUser()->getName() );
637 $this->assertSame(
$rev->getUser(), $record->getUser()->getId() );
638 $this->assertSame(
$rev->isMinor(), $record->isMinor() );
639 $this->assertSame(
$rev->getVisibility(), $record->getVisibility() );
640 $this->assertSame(
$rev->getSize(), $record->getSize() );
645 $expectedParent =
$rev->getParentId();
646 if ( $expectedParent ===
null ) {
649 $this->assertSame( $expectedParent, $record->getParentId() );
650 $this->assertSame(
$rev->getSha1(), $record->getSha1() );
651 $this->assertSame(
$rev->getComment(), $record->getComment()->text );
652 $this->assertSame(
$rev->getContentFormat(), $record->getContent(
'main' )->getDefaultFormat() );
653 $this->assertSame(
$rev->getContentModel(), $record->getContent(
'main' )->getModel() );
666 $text = __METHOD__ .
'a-ä';
668 $rev = $page->doEditContent(
671 )->value[
'revision'];
674 $record = $store->newRevisionFromRow(
680 $this->assertSame( $text,
$rev->getContent()->serialize() );
688 $this->
setMwGlobals(
'wgLegacyEncoding',
'windows-1252' );
691 $text = __METHOD__ .
'a-ä';
693 $rev = $page->doEditContent(
696 )->value[
'revision'];
699 $record = $store->newRevisionFromRow(
705 $this->assertSame( $text,
$rev->getContent()->serialize() );
717 $text = __METHOD__ .
'b-ä';
719 $rev = $page->doEditContent(
725 )->value[
'revision'];
728 $record = $store->newRevisionFromRow(
734 $this->assertSame( $text,
$rev->getContent()->serialize() );
742 $title = Title::newFromText( __METHOD__ );
743 $text = __METHOD__ .
'-bä';
746 $orig = $page->doEditContent(
new WikitextContent( $text ), __METHOD__ )
748 $page->doDeleteArticle( __METHOD__ );
751 $arQuery = $store->getArchiveQueryInfo();
753 $arQuery[
'tables'], $arQuery[
'fields'], [
'ar_rev_id' => $orig->getId() ],
754 __METHOD__, [], $arQuery[
'joins']
756 $this->assertTrue( is_object(
$res ),
'query failed' );
758 $row =
$res->fetchObject();
760 $record = $store->newRevisionFromArchiveRow( $row );
763 $this->assertSame( $text, $record->getContent(
'main' )->serialize() );
770 $this->
setMwGlobals(
'wgLegacyEncoding',
'windows-1252' );
773 $title = Title::newFromText( __METHOD__ );
774 $text = __METHOD__ .
'-bä';
777 $orig = $page->doEditContent(
new WikitextContent( $text ), __METHOD__ )
779 $page->doDeleteArticle( __METHOD__ );
782 $arQuery = $store->getArchiveQueryInfo();
784 $arQuery[
'tables'], $arQuery[
'fields'], [
'ar_rev_id' => $orig->getId() ],
785 __METHOD__, [], $arQuery[
'joins']
787 $this->assertTrue( is_object(
$res ),
'query failed' );
789 $row =
$res->fetchObject();
791 $record = $store->newRevisionFromArchiveRow( $row );
794 $this->assertSame( $text, $record->getContent(
'main' )->serialize() );
801 $title = Title::newFromText( __METHOD__ );
816 $title = Title::newFromText( __METHOD__ );
823 $result = $store->loadRevisionFromPageId(
wfGetDB(
DB_MASTER ), $page->getId() );
831 $title = Title::newFromText( __METHOD__ );
846 $title = Title::newFromText( __METHOD__ );
849 $revOne = $page->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ )
854 $revTwo = $page->doEditContent(
new WikitextContent( __METHOD__ .
'a' ),
'' )
859 $store->loadRevisionFromTimestamp(
wfGetDB(
DB_MASTER ), $title,
'20150101010101' )
863 $store->loadRevisionFromTimestamp(
866 $revOne->getTimestamp()
871 $store->loadRevisionFromTimestamp(
874 $revTwo->getTimestamp()
885 $revOne = $page->doEditContent(
887 )->value[
'revision'];
889 $revTwo = $page->doEditContent(
891 )->value[
'revision'];
896 $revOne->getId() => strlen( __METHOD__ ),
898 $store->listRevisionSizes(
905 $revOne->getId() => strlen( __METHOD__ ),
906 $revTwo->getId() => strlen( __METHOD__ ) + 1,
908 $store->listRevisionSizes(
910 [ $revOne->getId(), $revTwo->getId() ]
921 $revOne = $page->doEditContent(
923 )->value[
'revision'];
925 $revTwo = $page->doEditContent(
927 )->value[
'revision'];
931 $store->getPreviousRevision( $store->getRevisionById( $revOne->getId() ) )
935 $store->getPreviousRevision( $store->getRevisionById( $revTwo->getId() ) )->getId()
945 $revOne = $page->doEditContent(
947 )->value[
'revision'];
949 $revTwo = $page->doEditContent(
951 )->value[
'revision'];
956 $store->getNextRevision( $store->getRevisionById( $revOne->getId() ) )->getId()
959 $store->getNextRevision( $store->getRevisionById( $revTwo->getId() ) )
973 $result = $store->getTimestampFromId(
978 $this->assertSame(
$rev->getTimestamp(), $result );
991 $result = $store->getTimestampFromId(
996 $this->assertFalse( $result );
1051 $page->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
1054 $result = $store->userWasLastToEdit(
1060 $this->assertFalse( $result );
1070 $page->doEditContent(
1079 $result = $store->userWasLastToEdit(
1085 $this->assertTrue( $result );
1094 $rev = $page->doEditContent(
1100 )->value[
'revision'];
1103 $record = $store->getKnownCurrentRevision(
1112 yield
'Basic array, with page & id' => [
1117 'timestamp' =>
'20171017114835',
1118 'user_text' =>
'111.0.1.2',
1120 'minor_edit' =>
false,
1124 'sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1125 'comment' =>
'Goat Comment!',
1126 'content_format' =>
'text/x-wiki',
1127 'content_model' =>
'wikitext',
1130 yield
'Basic array, content object' => [
1134 'timestamp' =>
'20171017114835',
1135 'user_text' =>
'111.0.1.2',
1137 'minor_edit' =>
false,
1141 'sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1142 'comment' =>
'Goat Comment!',
1146 yield
'Basic array, serialized text' => [
1150 'timestamp' =>
'20171017114835',
1151 'user_text' =>
'111.0.1.2',
1153 'minor_edit' =>
false,
1157 'sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1158 'comment' =>
'Goat Comment!',
1162 yield
'Basic array, serialized text, utf-8 flags' => [
1166 'timestamp' =>
'20171017114835',
1167 'user_text' =>
'111.0.1.2',
1169 'minor_edit' =>
false,
1173 'sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1174 'comment' =>
'Goat Comment!',
1179 yield
'Basic array, with title' => [
1181 'title' => Title::newFromText(
'SomeText' ),
1183 'timestamp' =>
'20171017114835',
1184 'user_text' =>
'111.0.1.2',
1186 'minor_edit' =>
false,
1190 'sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1191 'comment' =>
'Goat Comment!',
1192 'content_format' =>
'text/x-wiki',
1193 'content_model' =>
'wikitext',
1196 yield
'Basic array, no user field' => [
1201 'timestamp' =>
'20171017114835',
1202 'user_text' =>
'111.0.1.3',
1203 'minor_edit' =>
false,
1207 'sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1208 'comment' =>
'Goat Comment!',
1209 'content_format' =>
'text/x-wiki',
1210 'content_model' =>
'wikitext',
1222 $result = $store->newMutableRevisionFromArray( $array );
1224 if ( isset( $array[
'id'] ) ) {
1225 $this->assertSame( $array[
'id'], $result->getId() );
1227 if ( isset( $array[
'page'] ) ) {
1228 $this->assertSame( $array[
'page'], $result->getPageId() );
1230 $this->assertSame( $array[
'timestamp'], $result->getTimestamp() );
1231 $this->assertSame( $array[
'user_text'], $result->getUser()->getName() );
1232 if ( isset( $array[
'user'] ) ) {
1233 $this->assertSame( $array[
'user'], $result->getUser()->getId() );
1235 $this->assertSame( (
bool)$array[
'minor_edit'], $result->isMinor() );
1236 $this->assertSame( $array[
'deleted'], $result->getVisibility() );
1237 $this->assertSame( $array[
'len'], $result->getSize() );
1238 $this->assertSame( $array[
'parent_id'], $result->getParentId() );
1239 $this->assertSame( $array[
'sha1'], $result->getSha1() );
1240 $this->assertSame( $array[
'comment'], $result->getComment()->text );
1241 if ( isset( $array[
'content'] ) ) {
1243 $result->getSlot(
'main' )->getContent()->equals( $array[
'content'] )
1245 } elseif ( isset( $array[
'text'] ) ) {
1246 $this->assertSame( $array[
'text'], $result->getSlot(
'main' )->getContent()->serialize() );
1249 $array[
'content_format'],
1250 $result->getSlot(
'main' )->getContent()->getDefaultFormat()
1252 $this->assertSame( $array[
'content_model'], $result->getSlot(
'main' )->getModel() );
1263 $blobStore->setLegacyEncoding(
'windows-1252', Language::factory(
'en' ) );
1265 $factory = $this->getMockBuilder( BlobStoreFactory::class )
1266 ->setMethods( [
'newBlobStore',
'newSqlBlobStore' ] )
1267 ->disableOriginalConstructor()
1269 $factory->expects( $this->
any() )
1270 ->method(
'newBlobStore' )
1271 ->willReturn( $blobStore );
1272 $factory->expects( $this->
any() )
1273 ->method(
'newSqlBlobStore' )
1274 ->willReturn( $blobStore );
1276 $this->
setService(
'BlobStoreFactory', $factory );
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetLB( $wiki=false)
Get a load balancer object.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Simple store for keeping values in an associative array for the current process.
Internationalisation code.
getTitle()
Returns the title of the page associated with this entry.
static getMutableTestUser( $testName, $groups=[])
Get a TestUser object that the caller may modify.
Represents a title within MediaWiki.
Multi-datacenter aware caching interface.
Class representing a MediaWiki article and history.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Content object for wiki text pages.
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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
const MIGRATION_WRITE_BOTH