5use InvalidArgumentException;
21 'slot_content_id' => 33,
22 'content_size' =>
'5',
23 'content_sha1' =>
'someHash',
24 'content_address' =>
'tt:456',
27 'slot_revision_id' =>
'2',
29 'role_name' =>
'myRole',
42 $this->
assertSame(
'A', $record->getContent()->getText() );
44 $this->
assertSame(
'someHash', $record->getSha1() );
46 $this->
assertSame( 2, $record->getRevision() );
48 $this->
assertSame(
'tt:456', $record->getAddress() );
49 $this->
assertSame( 33, $record->getContentId() );
51 $this->
assertSame(
'myRole', $record->getRole() );
56 'content_size' =>
null,
57 'content_sha1' =>
null,
58 'format_name' =>
function () {
61 'slot_revision_id' =>
'2',
63 'slot_content_id' =>
function () {
69 return new WikitextContent(
'A' );
78 $this->
assertSame(
'A', $record->getContent()->getText() );
82 $this->
assertSame( 2, $record->getRevision() );
83 $this->
assertSame( 2, $record->getRevision() );
84 $this->
assertSame(
'tt:456', $record->getAddress() );
86 $this->
assertSame(
'myRole', $record->getRole() );
90 $record = SlotRecord::newUnsaved(
'myRole',
new WikitextContent(
'A' ) );
97 $this->
assertSame(
'A', $record->getContent()->getText() );
101 $this->
assertSame(
'myRole', $record->getRole() );
105 yield
'both null' => [
null,
null ];
109 yield
'null content' => [ (
object)[],
null ];
121 $record = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
124 $record->getContentId();
128 $record = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
131 $record->getAddress();
135 $unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
139 $inherited = SlotRecord::newInherited(
$parent );
147 $record = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
150 $record->getRevision();
157 $record = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
160 $record->getOrigin();
164 yield [
'',
'phoiac9h4m842xq45sp7s6u21eteeq1' ];
165 yield [
'Lorem ipsum',
'hcr5u40uxr81d3nx89nvwzclfz6r9c5' ];
174 $this->
assertSame( $hash, SlotRecord::base36Sha1( $text ) );
176 $record = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent( $text ) );
177 $this->
assertSame( $hash, $record->getSha1() );
189 $row = $this->
makeRow( [
'slot_revision_id' => 7,
'slot_origin' => 7 ] );
193 $inherited = SlotRecord::newInherited(
$parent );
198 $this->
assertTrue( $inherited->isInherited() );
208 $saved = SlotRecord::newSaved(
210 $inherited->getContentId(),
211 $inherited->getAddress(),
219 $this->
assertSame( 10, $saved->getRevision() );
228 $unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
232 $saved = SlotRecord::newSaved( 10, 20,
'theNewAddress', $unsaved );
238 $this->
assertSame(
'theNewAddress', $saved->getAddress() );
239 $this->
assertSame( 20, $saved->getContentId() );
240 $this->
assertSame(
'A', $saved->getContent()->getText() );
241 $this->
assertSame( 10, $saved->getRevision() );
253 'content_address' =>
'address:1',
255 'slot_revision_id' => 1,
259 yield
'mismatching address' => [ 1, 10,
'address:BAD',
$freshSlot ];
260 yield
'mismatching revision' => [ 5, 10,
'address:1',
$freshSlot ];
261 yield
'mismatching content ID' => [ 1, 17,
'address:1',
$freshSlot ];
263 $inheritedRow = $this->
makeRow( [
264 'content_id' =>
null,
265 'content_address' =>
null,
267 'slot_revision_id' => 1,
271 yield
'inherited, but no address' => [ 1, 10,
'address:2',
$inheritedSlot ];
284 SlotRecord::newSaved( $revisionId, $contentId, $contentAddress, $protoSlot );
288 $unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
290 yield
'bad revision id' => [
'xyzzy', 5,
'address',
$unsaved ];
291 yield
'bad content id' => [ 7,
'xyzzy',
'address',
$unsaved ];
292 yield
'bad content address' => [ 7, 5, 77,
$unsaved ];
305 SlotRecord::newSaved( $revisionId, $contentId, $contentAddress, $protoSlot );
309 $fail =
function () {
310 self::fail(
'There should be no need to actually load the content.' );
317 'content_size' => 100,
318 'content_sha1' =>
'hash-a',
319 'content_address' =>
'xxx:a1',
328 'content_size' => 100,
329 'content_sha1' =>
'hash-a',
330 'content_address' =>
'xxx:a1',
339 'content_size' => 100,
340 'content_sha1' =>
'hash-a',
341 'content_address' =>
null,
350 'content_size' => 100,
351 'content_sha1' =>
'hash-a',
352 'content_address' =>
'xxx:a2',
361 'content_size' => 100,
362 'content_sha1' =>
'hash-a',
363 'content_address' =>
'xxx:a1',
372 'content_size' => 200,
373 'content_sha1' =>
'hash-a',
374 'content_address' =>
'xxx:a2',
383 'content_size' => 100,
384 'content_sha1' =>
'hash-x',
385 'content_address' =>
'xxx:x1',
404 $this->
assertSame( $sameContent, $a->hasSameContent( $b ) );
405 $this->
assertSame( $sameContent, $b->hasSameContent( $a ) );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Content object for wiki text pages.
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
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
processing should stop and the error should be shown to the user * false
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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 $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_FORMAT_WIKITEXT
if(is_array($mode)) switch( $mode) $input