31 protected abstract function newRevision( array $rowOverrides = [] );
34 yield
'field accessible for oversighter (ALL)' => [
35 RevisionRecord::SUPPRESSED_ALL,
41 yield
'field accessible for oversighter' => [
42 RevisionRecord::DELETED_RESTRICTED | $field,
48 yield
'field not accessible for sysops (ALL)' => [
49 RevisionRecord::SUPPRESSED_ALL,
55 yield
'field not accessible for sysops' => [
56 RevisionRecord::DELETED_RESTRICTED | $field,
62 yield
'field accessible for sysops' => [
69 yield
'field suppressed for logged in users' => [
76 yield
'unrelated field suppressed' => [
77 $field === RevisionRecord::DELETED_COMMENT
78 ? RevisionRecord::DELETED_USER
79 : RevisionRecord::DELETED_COMMENT,
85 yield
'nothing suppressed' => [
94 $this->setExpectedException( LogicException::class );
95 $rev = $this->newRevision();
105 'wgGroupPermissions',
108 'viewsuppressed' =>
false,
109 'suppressrevision' =>
false,
110 'deletedtext' =>
false,
111 'deletedhistory' =>
false,
114 'viewsuppressed' =>
false,
115 'suppressrevision' =>
false,
116 'deletedtext' =>
true,
117 'deletedhistory' =>
true,
120 'deletedtext' =>
true,
121 'deletedhistory' =>
true,
122 'viewsuppressed' =>
true,
123 'suppressrevision' =>
true,
135 $user = $this->getTestUser( $groups )->getUser();
136 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
138 $this->assertNotNull(
$rev->getComment( RevisionRecord::RAW ),
'raw can' );
142 $rev->getComment( RevisionRecord::FOR_PUBLIC ) !==
null,
147 $rev->getComment( RevisionRecord::FOR_THIS_USER, $user ) !==
null,
162 $user = $this->getTestUser( $groups )->getUser();
163 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
165 $this->assertNotNull(
$rev->getUser( RevisionRecord::RAW ),
'raw can' );
169 $rev->getUser( RevisionRecord::FOR_PUBLIC ) !==
null,
174 $rev->getUser( RevisionRecord::FOR_THIS_USER, $user ) !==
null,
189 $user = $this->getTestUser( $groups )->getUser();
190 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
193 $this->assertTrue(
$rev->hasSlot(
'main' ),
'hasSlot is never suppressed' );
194 $this->assertNotNull(
$rev->getSlot(
'main', RevisionRecord::RAW ),
'raw meta' );
195 $this->assertNotNull(
$rev->getSlot(
'main', RevisionRecord::FOR_PUBLIC ),
'public meta' );
197 $this->assertNotNull(
198 $rev->getSlot(
'main', RevisionRecord::FOR_THIS_USER, $user ),
203 $rev->getSlot(
'main', RevisionRecord::FOR_PUBLIC )->getContent();
216 $rev->getSlot(
'main', RevisionRecord::FOR_THIS_USER, $user )->getContent();
235 $user = $this->getTestUser( $groups )->getUser();
236 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
238 $this->assertNotNull(
$rev->getContent(
'main', RevisionRecord::RAW ),
'raw can' );
242 $rev->getContent(
'main', RevisionRecord::FOR_PUBLIC ) !==
null,
247 $rev->getContent(
'main', RevisionRecord::FOR_THIS_USER, $user ) !==
null,
253 $rev = $this->newRevision();
255 $slot =
$rev->getSlot(
'main' );
256 $this->assertNotNull( $slot,
'getSlot()' );
257 $this->assertSame(
'main', $slot->getRole(),
'getRole()' );
261 $rev = $this->newRevision();
263 $this->assertTrue(
$rev->hasSlot(
'main' ) );
264 $this->assertFalse(
$rev->hasSlot(
'xyz' ) );
268 $rev = $this->newRevision();
270 $content =
$rev->getSlot(
'main' );
271 $this->assertNotNull( $content,
'getContent()' );
276 yield [ 0, 0, [],
null,
true ];
279 RevisionRecord::DELETED_TEXT,
280 RevisionRecord::DELETED_TEXT,
286 RevisionRecord::DELETED_COMMENT,
287 RevisionRecord::DELETED_COMMENT,
293 RevisionRecord::DELETED_USER,
294 RevisionRecord::DELETED_USER,
300 RevisionRecord::DELETED_RESTRICTED,
301 RevisionRecord::DELETED_RESTRICTED,
308 RevisionRecord::DELETED_TEXT,
309 RevisionRecord::DELETED_TEXT,
315 RevisionRecord::DELETED_COMMENT,
316 RevisionRecord::DELETED_COMMENT,
322 RevisionRecord::DELETED_USER,
323 RevisionRecord::DELETED_USER,
330 RevisionRecord::DELETED_RESTRICTED,
331 RevisionRecord::DELETED_RESTRICTED,
338 RevisionRecord::DELETED_RESTRICTED,
339 RevisionRecord::DELETED_RESTRICTED,
346 RevisionRecord::DELETED_TEXT,
347 RevisionRecord::DELETED_TEXT,
349 Title::newFromText( __METHOD__ ),
353 RevisionRecord::DELETED_TEXT,
354 RevisionRecord::DELETED_TEXT,
356 Title::newFromText( __METHOD__ ),
368 $user = $this->getTestUser( $userGroups )->getUser();
372 RevisionRecord::userCanBitfield( $bitField, $field, $user, $title )
382 $recordCreator =
function ( array $slots, $revId ) {
383 $title = Title::newFromText(
'provideHasSameContent' );
384 $title->resetArticleID( 19 );
390 CommentStoreComment::newUnsavedComment( __METHOD__ ),
392 'rev_id' => strval( $revId ),
393 'rev_page' => strval( $title->getArticleID() ),
394 'rev_timestamp' =>
'20200101000000',
396 'rev_minor_edit' => 0,
397 'rev_parent_id' =>
'5',
398 'rev_len' => $slots->computeSize(),
399 'rev_sha1' => $slots->computeSha1(),
400 'page_latest' =>
'18',
407 $mainA = SlotRecord::newUnsaved(
'main',
new TextContent(
'A' ) );
408 $mainB = SlotRecord::newUnsaved(
'main',
new TextContent(
'B' ) );
409 $auxA = SlotRecord::newUnsaved(
'aux',
new TextContent(
'A' ) );
410 $auxB = SlotRecord::newUnsaved(
'aux',
new TextContent(
'A' ) );
412 $initialRecord = $recordCreator( [ $mainA ], 12 );
415 'same record object' => [
420 'same record content, different object' => [
422 $recordCreator( [ $mainA ], 12 ),
423 $recordCreator( [ $mainA ], 13 ),
425 'same record content, aux slot, different object' => [
427 $recordCreator( [ $auxA ], 12 ),
428 $recordCreator( [ $auxB ], 13 ),
430 'different content' => [
432 $recordCreator( [ $mainA ], 12 ),
433 $recordCreator( [ $mainB ], 13 ),
435 'different content and number of slots' => [
437 $recordCreator( [ $mainA ], 12 ),
438 $recordCreator( [ $mainA, $mainB ], 13 ),
455 $record1->hasSameContent( $record2 )
460 yield
'no deletion' => [
463 RevisionRecord::DELETED_TEXT =>
false,
464 RevisionRecord::DELETED_COMMENT =>
false,
465 RevisionRecord::DELETED_USER =>
false,
466 RevisionRecord::DELETED_RESTRICTED =>
false,
469 yield
'text deleted' => [
470 RevisionRecord::DELETED_TEXT,
472 RevisionRecord::DELETED_TEXT =>
true,
473 RevisionRecord::DELETED_COMMENT =>
false,
474 RevisionRecord::DELETED_USER =>
false,
475 RevisionRecord::DELETED_RESTRICTED =>
false,
478 yield
'text and comment deleted' => [
479 RevisionRecord::DELETED_TEXT + RevisionRecord::DELETED_COMMENT,
481 RevisionRecord::DELETED_TEXT =>
true,
482 RevisionRecord::DELETED_COMMENT =>
true,
483 RevisionRecord::DELETED_USER =>
false,
484 RevisionRecord::DELETED_RESTRICTED =>
false,
487 yield
'all 4 deleted' => [
488 RevisionRecord::DELETED_TEXT +
489 RevisionRecord::DELETED_COMMENT +
490 RevisionRecord::DELETED_RESTRICTED +
491 RevisionRecord::DELETED_USER,
493 RevisionRecord::DELETED_TEXT =>
true,
494 RevisionRecord::DELETED_COMMENT =>
true,
495 RevisionRecord::DELETED_USER =>
true,
496 RevisionRecord::DELETED_RESTRICTED =>
true,
506 $rev = $this->newRevision( [
'rev_deleted' => $revDeleted ] );
507 foreach ( $assertionMap as $deletionLevel => $expected ) {
508 $this->assertSame( $expected,
$rev->isDeleted( $deletionLevel ) );
Content object implementation for representing flat text.
Represents a title within MediaWiki.
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 noclasses just before the function returns a value If you return true
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