30 abstract protected function newRevision(
array $rowOverrides = [] );
33 yield
'field accessible for oversighter (ALL)' => [
34 RevisionRecord::SUPPRESSED_ALL,
40 yield
'field accessible for oversighter' => [
41 RevisionRecord::DELETED_RESTRICTED | $field,
47 yield
'field not accessible for sysops (ALL)' => [
48 RevisionRecord::SUPPRESSED_ALL,
54 yield
'field not accessible for sysops' => [
55 RevisionRecord::DELETED_RESTRICTED | $field,
61 yield
'field accessible for sysops' => [
68 yield
'field suppressed for logged in users' => [
75 yield
'unrelated field suppressed' => [
76 $field === RevisionRecord::DELETED_COMMENT
77 ? RevisionRecord::DELETED_USER
78 : RevisionRecord::DELETED_COMMENT,
84 yield
'nothing suppressed' => [
93 $this->setExpectedException( LogicException::class );
94 $rev = $this->newRevision();
104 'wgGroupPermissions',
107 'viewsuppressed' =>
false,
108 'suppressrevision' =>
false,
109 'deletedtext' =>
false,
110 'deletedhistory' =>
false,
113 'viewsuppressed' =>
false,
114 'suppressrevision' =>
false,
115 'deletedtext' =>
true,
116 'deletedhistory' =>
true,
119 'deletedtext' =>
true,
120 'deletedhistory' =>
true,
121 'viewsuppressed' =>
true,
122 'suppressrevision' =>
true,
134 $user = $this->getTestUser( $groups )->getUser();
135 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
137 $this->assertNotNull(
$rev->getComment( RevisionRecord::RAW ),
'raw can' );
141 $rev->getComment( RevisionRecord::FOR_PUBLIC ) !==
null,
146 $rev->getComment( RevisionRecord::FOR_THIS_USER,
$user ) !==
null,
161 $user = $this->getTestUser( $groups )->getUser();
162 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
164 $this->assertNotNull(
$rev->getUser( RevisionRecord::RAW ),
'raw can' );
168 $rev->getUser( RevisionRecord::FOR_PUBLIC ) !==
null,
173 $rev->getUser( RevisionRecord::FOR_THIS_USER,
$user ) !==
null,
188 $user = $this->getTestUser( $groups )->getUser();
189 $rev = $this->newRevision( [
'rev_deleted' => $visibility ] );
192 $this->assertTrue(
$rev->hasSlot( SlotRecord::MAIN ),
'hasSlot is never suppressed' );
193 $this->assertNotNull(
$rev->getSlot( SlotRecord::MAIN, RevisionRecord::RAW ),
'raw meta' );
194 $this->assertNotNull(
$rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_PUBLIC ),
197 $this->assertNotNull(
198 $rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_THIS_USER,
$user ),
203 $rev->getSlot( SlotRecord::MAIN, RevisionRecord::FOR_PUBLIC )->getContent();
216 $rev->getSlot( SlotRecord::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( SlotRecord::MAIN, RevisionRecord::RAW ),
'raw can' );
242 $rev->getContent( SlotRecord::MAIN, RevisionRecord::FOR_PUBLIC ) !==
null,
247 $rev->getContent( SlotRecord::MAIN, RevisionRecord::FOR_THIS_USER,
$user ) !==
null,
253 $rev = $this->newRevision();
255 $slot =
$rev->getSlot( SlotRecord::MAIN );
256 $this->assertNotNull( $slot,
'getSlot()' );
257 $this->assertSame(
'main', $slot->getRole(),
'getRole()' );
261 $rev = $this->newRevision();
263 $this->assertTrue(
$rev->hasSlot( SlotRecord::MAIN ) );
264 $this->assertFalse(
$rev->hasSlot(
'xyz' ) );
268 $rev = $this->newRevision();
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,
353 RevisionRecord::DELETED_TEXT,
354 RevisionRecord::DELETED_TEXT,
366 if ( is_string(
$title ) ) {
373 $user = $this->getTestUser( $userGroups )->getUser();
377 RevisionRecord::userCanBitfield( $bitField, $field,
$user,
$title )
383 $mainA = SlotRecord::newUnsaved( SlotRecord::MAIN,
new TextContent(
'A' ) );
384 $mainB = SlotRecord::newUnsaved( SlotRecord::MAIN,
new TextContent(
'B' ) );
385 $auxA = SlotRecord::newUnsaved(
'aux',
new TextContent(
'A' ) );
386 $auxB = SlotRecord::newUnsaved(
'aux',
new TextContent(
'A' ) );
388 $initialRecordSpec = [ [ $mainA ], 12 ];
391 'same record object' => [
396 'same record content, different object' => [
401 'same record content, aux slot, different object' => [
406 'different content' => [
411 'different content and number of slots' => [
414 [ [ $mainA, $mainB ], 13 ],
428 $title = Title::newFromText(
'provideHasSameContent' );
429 $title->resetArticleID( 19 );
435 CommentStoreComment::newUnsavedComment( __METHOD__ ),
437 'rev_id' => strval( $revId ),
438 'rev_page' => strval(
$title->getArticleID() ),
439 'rev_timestamp' =>
'20200101000000',
441 'rev_minor_edit' => 0,
442 'rev_parent_id' =>
'5',
443 'rev_len' => $slots->computeSize(),
444 'rev_sha1' => $slots->computeSha1(),
445 'page_latest' =>
'18',
466 $record1->hasSameContent( $record2 )
471 yield
'no deletion' => [
474 RevisionRecord::DELETED_TEXT =>
false,
475 RevisionRecord::DELETED_COMMENT =>
false,
476 RevisionRecord::DELETED_USER =>
false,
477 RevisionRecord::DELETED_RESTRICTED =>
false,
480 yield
'text deleted' => [
481 RevisionRecord::DELETED_TEXT,
483 RevisionRecord::DELETED_TEXT =>
true,
484 RevisionRecord::DELETED_COMMENT =>
false,
485 RevisionRecord::DELETED_USER =>
false,
486 RevisionRecord::DELETED_RESTRICTED =>
false,
489 yield
'text and comment deleted' => [
490 RevisionRecord::DELETED_TEXT + RevisionRecord::DELETED_COMMENT,
492 RevisionRecord::DELETED_TEXT =>
true,
493 RevisionRecord::DELETED_COMMENT =>
true,
494 RevisionRecord::DELETED_USER =>
false,
495 RevisionRecord::DELETED_RESTRICTED =>
false,
498 yield
'all 4 deleted' => [
499 RevisionRecord::DELETED_TEXT +
500 RevisionRecord::DELETED_COMMENT +
501 RevisionRecord::DELETED_RESTRICTED +
502 RevisionRecord::DELETED_USER,
504 RevisionRecord::DELETED_TEXT =>
true,
505 RevisionRecord::DELETED_COMMENT =>
true,
506 RevisionRecord::DELETED_USER =>
true,
507 RevisionRecord::DELETED_RESTRICTED =>
true,
517 $rev = $this->newRevision( [
'rev_deleted' => $revDeleted ] );
518 foreach ( $assertionMap
as $deletionLevel => $expected ) {
519 $this->assertSame( $expected,
$rev->isDeleted( $deletionLevel ) );
524 $rev = $this->newRevision();
525 $this->assertTrue(
$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.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
processing should stop and the error should be shown to the user * false
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))