21 yield
'with text' => [
23 'text' =>
'hello world.',
27 yield
'with content' => [
41 $mock = $this->getMockBuilder( Title::class )
42 ->disableOriginalConstructor()
44 $mock->expects( $this->
any() )
45 ->method(
'getNamespace' )
47 $mock->expects( $this->
any() )
48 ->method(
'getPrefixedText' )
49 ->will( $this->returnValue(
'RevisionTest' ) );
50 $mock->expects( $this->
any() )
51 ->method(
'getDBkey' )
52 ->will( $this->returnValue(
'RevisionTest' ) );
53 $mock->expects( $this->
any() )
54 ->method(
'getArticleID' )
55 ->will( $this->returnValue( 23 ) );
56 $mock->expects( $this->
any() )
57 ->method(
'getContentModel' )
58 ->will( $this->returnValue( $model ) );
70 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
81 $this->assertNull(
$rev->getContent(),
'no content object should be available' );
89 Wikimedia\suppressWarnings();
91 $this->assertSame( 77777777,
$rev->getPage() );
92 Wikimedia\restoreWarnings();
96 yield
'no user defaults to wgUser' => [
103 yield
'user text and id' => [
106 'user_text' =>
'SomeTextUserName',
113 yield
'user text only' => [
116 'user_text' =>
'111.111.111.111',
139 if ( $expectedUserId ===
null ) {
140 $expectedUserId = $testUser->getId();
142 if ( $expectedUserName ===
null ) {
143 $expectedUserName = $testUser->getName();
147 $this->assertEquals( $expectedUserId,
$rev->getUser() );
148 $this->assertEquals( $expectedUserName,
$rev->getUserText() );
152 yield
'content and text_id both not empty' => [
155 'text_id' =>
'someid',
157 new MWException(
"Text already stored in external store (id someid), " .
158 "can't serialize content object" )
160 yield
'with bad content object (class)' => [
161 [
'content' =>
new stdClass() ],
162 new MWException(
'content field must contain a Content object.' )
164 yield
'with bad content object (string)' => [
165 [
'content' =>
'ImAGoat' ],
166 new MWException(
'content field must contain a Content object.' )
168 yield
'bad row format' => [
169 'imastring, not a row',
170 new InvalidArgumentException(
171 '$row must be a row object, an associative array, or a RevisionRecord'
182 $this->setExpectedException(
183 get_class( $expectedException ),
184 $expectedException->getMessage(),
185 $expectedException->getCode()
195 $this->setExpectedException(
196 InvalidArgumentException::class
202 yield
'Full construction' => [
206 'rev_text_id' =>
'2',
207 'rev_timestamp' =>
'20171017114835',
208 'rev_user_text' =>
'127.0.0.1',
210 'rev_minor_edit' =>
'0',
211 'rev_deleted' =>
'0',
213 'rev_parent_id' =>
'1',
214 'rev_sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
215 'rev_comment_text' =>
'Goat Comment!',
216 'rev_comment_data' =>
null,
217 'rev_comment_cid' =>
null,
218 'rev_content_format' =>
'GOATFORMAT',
219 'rev_content_model' =>
'GOATMODEL',
222 $testCase->assertSame( 42,
$rev->getId() );
223 $testCase->assertSame( 23,
$rev->getPage() );
224 $testCase->assertSame( 2,
$rev->getTextId() );
225 $testCase->assertSame(
'20171017114835',
$rev->getTimestamp() );
226 $testCase->assertSame(
'127.0.0.1',
$rev->getUserText() );
227 $testCase->assertSame( 0,
$rev->getUser() );
228 $testCase->assertSame(
false,
$rev->isMinor() );
229 $testCase->assertSame(
false,
$rev->isDeleted( Revision::DELETED_TEXT ) );
230 $testCase->assertSame( 46,
$rev->getSize() );
231 $testCase->assertSame( 1,
$rev->getParentId() );
232 $testCase->assertSame(
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
$rev->getSha1() );
233 $testCase->assertSame(
'Goat Comment!',
$rev->getComment() );
234 $testCase->assertSame(
'GOATFORMAT',
$rev->getContentFormat() );
235 $testCase->assertSame(
'GOATMODEL',
$rev->getContentModel() );
238 yield
'default field values' => [
242 'rev_text_id' =>
'2',
243 'rev_timestamp' =>
'20171017114835',
244 'rev_user_text' =>
'127.0.0.1',
246 'rev_minor_edit' =>
'0',
247 'rev_deleted' =>
'0',
248 'rev_comment_text' =>
'Goat Comment!',
249 'rev_comment_data' =>
null,
250 'rev_comment_cid' =>
null,
254 $testCase->assertSame(
null,
$rev->getParentId(),
'revision id' );
257 $testCase->assertSame(
$rev->getTimestamp(),
'20171017114835',
'timestamp' );
258 $testCase->assertSame(
$rev->getUserText(),
'127.0.0.1',
'user name' );
259 $testCase->assertSame(
$rev->getUser(), 0,
'user id' );
260 $testCase->assertSame(
$rev->getComment(),
'Goat Comment!' );
261 $testCase->assertSame(
false,
$rev->isMinor(),
'minor edit' );
262 $testCase->assertSame( 0,
$rev->getVisibility(),
'visibility flags' );
265 $testCase->assertNotNull(
$rev->getSize(),
'size' );
266 $testCase->assertNotNull(
$rev->getSha1(),
'hash' );
269 $testCase->assertSame(
'text/x-wiki',
$rev->getContentFormat(),
'format' );
270 $testCase->assertSame(
'wikitext',
$rev->getContentModel(),
'model' );
281 $data =
'Hello goat.';
283 $blobStore = $this->getMockBuilder( SqlBlobStore::class )
284 ->disableOriginalConstructor()
287 $blobStore->method(
'getBlob' )
288 ->will( $this->returnValue( $data ) );
290 $blobStore->method(
'getTextIdFromAddress' )
291 ->will( $this->returnCallback(
292 function ( $address ) {
296 $parts = explode(
':', $address );
297 return (
int)array_pop( $parts );
304 $row = (
object)$arrayData;
306 $assertions( $this,
$rev );
316 Wikimedia\suppressWarnings();
317 $rev =
new Revision( (
object)[
'rev_page' => 77777777 ] );
318 $this->assertSame( 77777777,
$rev->getPage() );
319 Wikimedia\restoreWarnings();
323 yield
'Generic test' => [
324 'This is a goat of revision text.',
327 'old_text' =>
'This is a goat of revision text.',
349 $this->assertEquals( $expectedId,
$rev->getId() );
353 yield [
'123', 123 ];
364 $this->assertSame( $expected,
$rev->getId() );
368 yield [
'123', 123,
'GOaT' ];
369 yield [ 456, 456,
'GOaT' ];
378 $rev->setUserIdAndName( $inputId, $name );
379 $this->assertSame( $expectedId,
$rev->getUser( Revision::RAW ) );
380 $this->assertEquals( $name,
$rev->getUserText( Revision::RAW ) );
385 yield [ [
'text_id' =>
'123' ], 123 ];
386 yield [ [
'text_id' => 456 ], 456 ];
395 $this->assertSame( $expected,
$rev->getTextId() );
400 yield [ [
'parent_id' =>
'123' ], 123 ];
401 yield [ [
'parent_id' => 456 ], 456 ];
410 $this->assertSame( $expected,
$rev->getParentId() );
420 Revision::getRevisionText( (
object)$rowData, $prefix, $wiki ) );
424 yield
'Generic gzip test' => [
425 'This is a small goat of revision text.',
427 'old_flags' =>
'gzip',
428 'old_text' => gzdeflate(
'This is a small goat of revision text.' ),
451 $lb = $this->getMockBuilder( LoadBalancer::class )
452 ->disableOriginalConstructor()
463 $factory = $this->getMockBuilder( BlobStoreFactory::class )
464 ->disableOriginalConstructor()
466 $factory->expects( $this->
any() )
467 ->method(
'newBlobStore' )
468 ->willReturn( $blobStore );
469 $factory->expects( $this->
any() )
470 ->method(
'newSqlBlobStore' )
471 ->willReturn( $blobStore );
480 $lb = $this->getMockBuilder( LoadBalancer::class )
481 ->disableOriginalConstructor()
490 MediaWikiServices::getInstance()->getCommentStore(),
491 MediaWikiServices::getInstance()->getActorMigration()
497 yield
'Utf8Native' => [
498 "Wiki est l'\xc3\xa9cole superieur !",
502 'old_flags' =>
'utf-8',
503 'old_text' =>
"Wiki est l'\xc3\xa9cole superieur !",
506 yield
'Utf8Legacy' => [
507 "Wiki est l'\xc3\xa9cole superieur !",
512 'old_text' =>
"Wiki est l'\xe9cole superieur !",
523 $blobStore->setLegacyEncoding( $encoding, Language::factory(
$lang ) );
535 yield
'Utf8NativeGzip' => [
536 "Wiki est l'\xc3\xa9cole superieur !",
540 'old_flags' =>
'gzip,utf-8',
541 'old_text' => gzdeflate(
"Wiki est l'\xc3\xa9cole superieur !" ),
544 yield
'Utf8LegacyGzip' => [
545 "Wiki est l'\xc3\xa9cole superieur !",
549 'old_flags' =>
'gzip',
550 'old_text' => gzdeflate(
"Wiki est l'\xe9cole superieur !" ),
563 $blobStore->setLegacyEncoding( $encoding, Language::factory(
$lang ) );
574 $row->old_text =
"Wiki est l'\xc3\xa9cole superieur !";
575 $row->old_flags = Revision::compressRevisionText( $row->old_text );
576 $this->assertTrue(
false !== strpos( $row->old_flags,
'utf-8' ),
577 "Flags should contain 'utf-8'" );
578 $this->assertFalse(
false !== strpos( $row->old_flags,
'gzip' ),
579 "Flags should not contain 'gzip'" );
580 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
581 $row->old_text,
"Direct check" );
582 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
583 Revision::getRevisionText( $row ),
"getRevisionText" );
593 $blobStore->setCompressBlobs(
true );
597 $row->old_text =
"Wiki est l'\xc3\xa9cole superieur !";
598 $row->old_flags = Revision::compressRevisionText( $row->old_text );
599 $this->assertTrue(
false !== strpos( $row->old_flags,
'utf-8' ),
600 "Flags should contain 'utf-8'" );
601 $this->assertTrue(
false !== strpos( $row->old_flags,
'gzip' ),
602 "Flags should contain 'gzip'" );
603 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
604 gzinflate( $row->old_text ),
"Direct check" );
605 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
606 Revision::getRevisionText( $row ),
"getRevisionText" );
619 'rev_id=page_latest',
620 'page_namespace' => $title->getNamespace(),
621 'page_title' => $title->getDBkey()
626 'rev_page' => $title->getArticleID(),
627 'rev_text_id' =>
'2',
628 'rev_timestamp' =>
'20171017114835',
629 'rev_user_text' =>
'127.0.0.1',
631 'rev_minor_edit' =>
'0',
632 'rev_deleted' =>
'0',
634 'rev_parent_id' =>
'1',
635 'rev_sha1' =>
'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
636 'rev_comment_text' =>
'Goat Comment!',
637 'rev_comment_data' =>
null,
638 'rev_comment_cid' =>
null,
639 'rev_content_format' =>
'GOATFORMAT',
640 'rev_content_model' =>
'GOATMODEL',
643 $db = $this->getMock( IDatabase::class );
644 $db->expects( $this->
any() )
645 ->method(
'getDomainId' )
646 ->will( $this->returnValue(
wfWikiID() ) );
647 $db->expects( $this->once() )
648 ->method(
'selectRow' )
650 $this->equalTo( [
'revision',
'page',
'user' ] ),
652 $this->isType(
'array' ),
653 $this->equalTo( $conditions ),
655 $this->stringContains(
'fetchRevisionRowFromConds' ),
657 $this->isType(
'array' ),
659 $this->isType(
'array' )
661 ->willReturn( $row );
663 $revision = Revision::loadFromTitle(
$db, $title );
665 $this->assertEquals( $title->getArticleID(), $revision->getTitle()->getArticleID() );
666 $this->assertEquals( $row->rev_id, $revision->getId() );
667 $this->assertEquals( $row->rev_len, $revision->getSize() );
668 $this->assertEquals( $row->rev_sha1, $revision->getSha1() );
669 $this->assertEquals( $row->rev_parent_id, $revision->getParentId() );
670 $this->assertEquals( $row->rev_timestamp, $revision->getTimestamp() );
671 $this->assertEquals( $row->rev_comment_text, $revision->getComment() );
672 $this->assertEquals( $row->rev_user_text, $revision->getUserText() );
676 yield
'(no legacy encoding), false in false out' => [
false,
false, [],
false ];
677 yield
'(no legacy encoding), empty in empty out' => [
false,
'', [],
'' ];
678 yield
'(no legacy encoding), empty in empty out' => [
false,
'A', [],
'A' ];
679 yield
'(no legacy encoding), string in with gzip flag returns string' => [
681 false,
"sttttr\002\022\000", [
'gzip' ],
'AAAABBAAA',
683 yield
'(no legacy encoding), string in with object flag returns false' => [
685 false,
"s:4:\"JOJO\";", [
'object' ],
false,
687 yield
'(no legacy encoding), serialized object in with object flag returns string' => [
694 yield
'(no legacy encoding), serialized object in with object & gzip flag returns string' => [
698 [
'object',
'gzip' ],
701 yield
'(ISO-8859-1 encoding), string in string out' => [
703 iconv(
'utf-8',
'ISO-8859-1',
"1®Àþ1" ),
707 yield
'(ISO-8859-1 encoding), serialized object in with gzip flags returns string' => [
709 gzdeflate( iconv(
'utf-8',
'ISO-8859-1',
"4®Àþ4" ) ),
713 yield
'(ISO-8859-1 encoding), serialized object in with object flags returns string' => [
719 yield
'(ISO-8859-1 encoding), serialized object in with object & gzip flags returns string' => [
722 [
'gzip',
'object' ],
738 if ( $legacyEncoding ) {
739 $blobStore->setLegacyEncoding( $legacyEncoding, Language::factory(
'en' ) );
745 Revision::decompressRevisionText( $text, $flags )
753 $this->assertFalse( Revision::getRevisionText(
new stdClass() ) );
757 yield
'Just text' => [
758 (
object)[
'old_text' =>
'SomeText' ],
763 yield
'gzip text' => [
765 'old_text' =>
"sttttr\002\022\000",
766 'old_flags' =>
'gzip'
771 yield
'gzip text and different prefix' => [
773 'jojo_text' =>
"sttttr\002\022\000",
774 'jojo_flags' =>
'gzip'
790 $this->assertSame( $expected, Revision::getRevisionText( $row, $prefix ) );
794 yield
'Just some text' => [
'someNonUrlText' ];
795 yield
'No second URL part' => [
'someProtocol://' ];
806 Revision::getRevisionText(
809 'old_flags' =>
'external',
820 'ExternalStoreFactory',
825 Revision::getRevisionText(
827 'old_text' =>
'ForTesting://cluster1/12345',
828 'old_flags' =>
'external,gzip',
842 'ExternalStoreFactory',
846 $lb = $this->getMockBuilder( LoadBalancer::class )
847 ->disableOriginalConstructor()
855 Revision::getRevisionText(
857 'old_text' =>
'ForTesting://cluster1/12345',
858 'old_flags' =>
'external,gzip',
864 $cacheKey =
$cache->makeKey(
'revisiontext',
'textid',
'tt:7777' );
865 $this->assertSame(
'AAAABBAAA',
$cache->get( $cacheKey ) );
876 [
'LEFT JOIN', [
'rev_user != 0',
'user_id = rev_user' ] ],
877 Revision::userJoinCond()
887 [
'INNER JOIN', [
'page_id = rev_page' ] ],
888 Revision::pageJoinCond()
893 $mockStore = $this->getMockBuilder( CommentStore::class )
894 ->disableOriginalConstructor()
896 $mockStore->expects( $this->
any() )
897 ->method(
'getFields' )
898 ->willReturn( [
'commentstore' =>
'fields' ] );
899 $mockStore->expects( $this->
any() )
900 ->method(
'getJoin' )
902 'tables' => [
'commentstore' =>
'table' ],
903 'fields' => [
'commentstore' =>
'field' ],
904 'joins' => [
'commentstore' =>
'join' ],
906 $this->
setService(
'CommentStore', $mockStore );
908 $mockStore = $this->getMockBuilder( ActorMigration::class )
909 ->disableOriginalConstructor()
911 $mockStore->expects( $this->
any() )
912 ->method(
'getJoin' )
913 ->willReturnCallback(
function ( $key ) {
914 $p = strtok( $key,
'_' );
916 'tables' => [
'actormigration' =>
'table' ],
918 $p .
'_user' =>
'actormigration_user',
919 $p .
'_user_text' =>
'actormigration_user_text',
920 $p .
'_actor' =>
'actormigration_actor',
922 'joins' => [
'actormigration' =>
'join' ],
925 $this->
setService(
'ActorMigration', $mockStore );
938 'rev_actor' =>
'NULL',
944 'commentstore' =>
'fields',
945 'rev_content_format',
958 'rev_actor' =>
'NULL',
964 'commentstore' =>
'fields',
975 $this->
setMwGlobals(
'wgContentHandlerUseDB', $contentHandlerUseDB );
978 $this->assertEquals( $expected, Revision::selectFields() );
992 'ar_actor' =>
'NULL',
998 'commentstore' =>
'fields',
1013 'ar_actor' =>
'NULL',
1019 'commentstore' =>
'fields',
1030 $this->
setMwGlobals(
'wgContentHandlerUseDB', $contentHandlerUseDB );
1033 $this->assertEquals( $expected, Revision::selectArchiveFields() );
1041 $this->assertEquals(
1046 Revision::selectTextFields()
1055 $this->assertEquals(
1064 Revision::selectPageFields()
1073 $this->assertEquals(
1077 Revision::selectUserFields()
1082 yield
'wgContentHandlerUseDB false' => [
1084 'wgContentHandlerUseDB' =>
false,
1089 'commentstore' =>
'table',
1090 'actormigration' =>
'table',
1105 'commentstore' =>
'field',
1106 'ar_user' =>
'actormigration_user',
1107 'ar_user_text' =>
'actormigration_user_text',
1108 'ar_actor' =>
'actormigration_actor',
1110 'joins' => [
'commentstore' =>
'join',
'actormigration' =>
'join' ],
1113 yield
'wgContentHandlerUseDB true' => [
1115 'wgContentHandlerUseDB' =>
true,
1120 'commentstore' =>
'table',
1121 'actormigration' =>
'table',
1136 'commentstore' =>
'field',
1137 'ar_user' =>
'actormigration_user',
1138 'ar_user_text' =>
'actormigration_user_text',
1139 'ar_actor' =>
'actormigration_actor',
1140 'ar_content_format',
1143 'joins' => [
'commentstore' =>
'join',
'actormigration' =>
'join' ],
1157 $revisionStore->setContentHandlerUseDB( $globals[
'wgContentHandlerUseDB'] );
1158 $this->
setService(
'RevisionStore', $revisionStore );
1159 $this->assertEquals(
1161 Revision::getArchiveQueryInfo()
1166 yield
'wgContentHandlerUseDB false, opts none' => [
1168 'wgContentHandlerUseDB' =>
false,
1172 'tables' => [
'revision',
'commentstore' =>
'table',
'actormigration' =>
'table' ],
1183 'commentstore' =>
'field',
1184 'rev_user' =>
'actormigration_user',
1185 'rev_user_text' =>
'actormigration_user_text',
1186 'rev_actor' =>
'actormigration_actor',
1188 'joins' => [
'commentstore' =>
'join',
'actormigration' =>
'join' ],
1191 yield
'wgContentHandlerUseDB false, opts page' => [
1193 'wgContentHandlerUseDB' =>
false,
1197 'tables' => [
'revision',
'commentstore' =>
'table',
'actormigration' =>
'table',
'page' ],
1208 'commentstore' =>
'field',
1209 'rev_user' =>
'actormigration_user',
1210 'rev_user_text' =>
'actormigration_user_text',
1211 'rev_actor' =>
'actormigration_actor',
1222 [
'page_id = rev_page' ],
1224 'commentstore' =>
'join',
1225 'actormigration' =>
'join',
1229 yield
'wgContentHandlerUseDB false, opts user' => [
1231 'wgContentHandlerUseDB' =>
false,
1235 'tables' => [
'revision',
'commentstore' =>
'table',
'actormigration' =>
'table',
'user' ],
1246 'commentstore' =>
'field',
1247 'rev_user' =>
'actormigration_user',
1248 'rev_user_text' =>
'actormigration_user_text',
1249 'rev_actor' =>
'actormigration_actor',
1256 'actormigration_user != 0',
1257 'user_id = actormigration_user',
1260 'commentstore' =>
'join',
1261 'actormigration' =>
'join',
1265 yield
'wgContentHandlerUseDB false, opts text' => [
1267 'wgContentHandlerUseDB' =>
false,
1271 'tables' => [
'revision',
'commentstore' =>
'table',
'actormigration' =>
'table',
'text' ],
1282 'commentstore' =>
'field',
1283 'rev_user' =>
'actormigration_user',
1284 'rev_user_text' =>
'actormigration_user_text',
1285 'rev_actor' =>
'actormigration_actor',
1292 [
'rev_text_id=old_id' ],
1294 'commentstore' =>
'join',
1295 'actormigration' =>
'join',
1299 yield
'wgContentHandlerUseDB false, opts 3' => [
1301 'wgContentHandlerUseDB' =>
false,
1303 [
'text',
'page',
'user' ],
1306 'revision',
'commentstore' =>
'table',
'actormigration' =>
'table',
'page',
'user',
'text'
1318 'commentstore' =>
'field',
1319 'rev_user' =>
'actormigration_user',
1320 'rev_user_text' =>
'actormigration_user_text',
1321 'rev_actor' =>
'actormigration_actor',
1335 [
'page_id = rev_page' ],
1340 'actormigration_user != 0',
1341 'user_id = actormigration_user',
1346 [
'rev_text_id=old_id' ],
1348 'commentstore' =>
'join',
1349 'actormigration' =>
'join',
1353 yield
'wgContentHandlerUseDB true, opts none' => [
1355 'wgContentHandlerUseDB' =>
true,
1359 'tables' => [
'revision',
'commentstore' =>
'table',
'actormigration' =>
'table' ],
1370 'commentstore' =>
'field',
1371 'rev_user' =>
'actormigration_user',
1372 'rev_user_text' =>
'actormigration_user_text',
1373 'rev_actor' =>
'actormigration_actor',
1374 'rev_content_format',
1375 'rev_content_model',
1377 'joins' => [
'commentstore' =>
'join',
'actormigration' =>
'join' ],
1391 $revisionStore->setContentHandlerUseDB( $globals[
'wgContentHandlerUseDB'] );
1392 $this->
setService(
'RevisionStore', $revisionStore );
1394 $this->assertEquals(
1409 $this->assertSame( 0,
$rev->getSize(),
'Size of no slots is 0' );
1411 $rec->setSize( 13 );
1412 $this->assertSame( 13,
$rev->getSize() );
1421 $rec = $this->getMockBuilder( RevisionRecord::class )
1422 ->disableOriginalConstructor()
1425 $rec->method(
'getSize' )
1429 $this->assertNull(
$rev->getSize() );
1441 $emptyHash = SlotRecord::base36Sha1(
'' );
1442 $this->assertSame( $emptyHash,
$rev->getSha1(),
'Sha1 of no slots is hash of empty string' );
1444 $rec->setSha1(
'deadbeef' );
1445 $this->assertSame(
'deadbeef',
$rev->getSha1() );
1454 $rec = $this->getMockBuilder( RevisionRecord::class )
1455 ->disableOriginalConstructor()
1458 $rec->method(
'getSha1' )
1462 $this->assertNull(
$rev->getSha1() );
1474 $this->assertNull(
$rev->getContent(),
'Content of no slots is null' );
1477 $rec->setContent(
'main', $content );
1478 $this->assertSame( $content,
$rev->getContent() );
1487 $rec = $this->getMockBuilder( RevisionRecord::class )
1488 ->disableOriginalConstructor()
1491 $rec->method(
'getContent' )
1495 $this->assertNull(
$rev->getContent() );
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Simple store for keeping values in an associative array for the current process.
Content for JavaScript pages.
Test cases in RevisionTest should not interact with the Database.
testConstructFromEmptyArray()
Revision::__construct \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray.
testSetUserIdAndName( $inputId, $expectedId, $name)
provideSetUserIdAndName Revision::setUserIdAndName
provideConstructFromArray()
testUserJoinCond()
Revision::userJoinCond.
testGetRevisionWithGzipAndLegacyEncoding( $expected, $lang, $encoding, $rowData)
Revision::getRevisionText provideGetRevisionTextWithGzipAndLegacyEncoding.
testSelectUserFields()
Revision::selectUserFields.
testConstructFromArray( $rowArray)
provideConstructFromArray Revision::__construct \MediaWiki\Storage\RevisionStore::newMutableRevisionF...
testGetParentId( $rowArray, $expected)
provideGetParentId Revision::getParentId()
testGetId( $rowArray, $expectedId)
provideGetId Revision::getId
provideGetArchiveQueryInfo()
testGetSize()
Revision::getSize.
testConstructFromRowWithBadPageId()
Revision::__construct \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray.
overrideCommentStoreAndActorMigration()
testSetId( $input, $expected)
provideSetId Revision::setId
testSelectPageFields()
Revision::selectPageFields.
testGetRevisionWithZlibExtension( $expected, $rowData)
Revision::getRevisionText provideGetRevisionTextWithZlibExtension.
provideConstructFromRow()
provideGetRevisionTextWithLegacyEncoding()
testConstructFromArrayWithBadPageId()
Revision::__construct \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray.
testSelectTextFields()
Revision::selectTextFields.
testGetSize_failure()
Revision::getSize.
mockBlobStoreFactory( $blobStore)
provideSetUserIdAndName()
provideDecompressRevisionText()
provideConstructFromArrayThrowsExceptions()
testConstructFromRow(array $arrayData, $assertions)
provideConstructFromRow Revision::__construct \MediaWiki\Storage\RevisionStore::newMutableRevisionFro...
testConstructFromArrayThrowsExceptions( $rowArray, Exception $expectedException)
provideConstructFromArrayThrowsExceptions Revision::__construct \MediaWiki\Storage\RevisionStore::new...
provideGetRevisionTextWithZlibExtension()
testGetRevisionText( $expected, $rowData, $prefix='old_', $wiki=false)
Revision::getRevisionText provideGetRevisionText.
testGetTextId( $rowArray, $expected)
provideGetTextId Revision::getTextId()
testGetArchiveQueryInfo( $globals, $expected)
Revision::getArchiveQueryInfo provideGetArchiveQueryInfo.
testGetSha1()
Revision::getSha1.
testCompressRevisionTextUtf8()
Revision::compressRevisionText.
testGetSha1_failure()
Revision::getSha1.
testGetRevisionText_returnsDecompressedTextFieldWhenNotExternal( $row, $prefix, $expected)
provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal Revision::getRevisionText
provideConstructFromArray_userSetAsExpected()
testGetContent()
Revision::getContent.
testConstructFromArray_userSetAsExpected(array $rowArray, $expectedUserId, $expectedUserName)
provideConstructFromArray_userSetAsExpected Revision::__construct \MediaWiki\Storage\RevisionStore::n...
testGetRevisionWithLegacyEncoding( $expected, $lang, $encoding, $rowData)
Revision::getRevisionText provideGetRevisionTextWithLegacyEncoding.
provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal()
provideGetRevisionTextWithGzipAndLegacyEncoding()
testGetRevisionText_returnsFalseWhenNoTextField()
Revision::getRevisionText.
testDecompressRevisionText( $legacyEncoding, $text, $flags, $expected)
provideDecompressRevisionText Revision::decompressRevisionText
getMockTitle( $model=CONTENT_MODEL_WIKITEXT)
testGetContent_failure()
Revision::getContent.
testSelectFields( $contentHandlerUseDB, $expected)
provideSelectFields Revision::selectFields
testLoadFromTitle()
Revision::loadFromTitle.
testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts( $text)
provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts Revision::getRevisionText
testGetQueryInfo( $globals, $options, $expected)
Revision::getQueryInfo provideGetQueryInfo.
testGetRevisionText_external_noOldId()
Revision::getRevisionText.
testPageJoinCond()
Revision::pageJoinCond.
testSelectArchiveFields( $contentHandlerUseDB, $expected)
provideSelectArchiveFields Revision::selectArchiveFields
provideSelectArchiveFields()
provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts()
testCompressRevisionTextUtf8Gzip()
Revision::compressRevisionText.
testConstructFromNothing()
Revision::__construct \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray.
testGetRevisionText_external_oldId()
Revision::getRevisionText.
Content object implementation for representing flat text.
Represents a page (or page fragment) title within MediaWiki.
Multi-datacenter aware caching interface.
Content object for wiki text pages.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
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
processing should stop and the error should be shown to the user * false
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 For a description of the see design txt $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
const CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
if(is_array($mode)) switch( $mode) $input
if(!isset( $args[0])) $lang