19 function __construct( $name =
null, array $data = [], $dataName =
'' ) {
20 parent::__construct( $name, $data, $dataName );
22 $this->tablesUsed = array_merge( $this->tablesUsed,
49 $wgNamespaceContentModels[12312] =
'DUMMY';
52 MWNamespace::getCanonicalNamespaces(
true ); # reset
namespace cache
54 if ( !$this->the_page ) {
55 $this->the_page = $this->createPage(
56 'RevisionStorageTest_the_page',
62 $this->tablesUsed[] =
'archive';
73 unset( $wgNamespaceContentModels[12312] );
76 MWNamespace::getCanonicalNamespaces(
true ); # reset
namespace cache
81 if ( $props ===
null ) {
85 if ( !isset( $props[
'content'] ) && !isset( $props[
'text'] ) ) {
86 $props[
'text'] =
'Lorem Ipsum';
89 if ( !isset( $props[
'comment'] ) ) {
90 $props[
'comment'] =
'just a test';
93 if ( !isset( $props[
'page'] ) ) {
94 $props[
'page'] = $this->the_page->getId();
100 $rev->insertOn( $dbw );
105 protected function createPage( $page, $text, $model =
null ) {
106 if ( is_string( $page ) ) {
107 if ( !preg_match(
'/:/', $page ) &&
111 $page = MWNamespace::getCanonicalName( $ns ) .
':' . $page;
114 $page = Title::newFromText( $page );
117 if ( $page instanceof
Title ) {
121 if ( $page->exists() ) {
122 $page->doDeleteArticle(
"done" );
126 $page->doEditContent( $content,
"testing",
EDIT_NEW );
132 $this->assertNotNull(
$rev,
'missing revision' );
134 $this->assertEquals( $orig->
getId(),
$rev->getId() );
135 $this->assertEquals( $orig->
getPage(),
$rev->getPage() );
137 $this->assertEquals( $orig->
getUser(),
$rev->getUser() );
140 $this->assertEquals( $orig->
getSha1(),
$rev->getSha1() );
151 $this->assertTrue( is_object(
$res ),
'query failed' );
153 $row =
$res->fetchObject();
169 $this->assertTrue( is_object(
$res ),
'query failed' );
171 $row =
$res->fetchObject();
184 'RevisionStorageTest_testNewFromArchiveRow',
188 $orig = $page->getRevision();
189 $page->doDeleteArticle(
'test Revision::newFromArchiveRow' );
195 $this->assertTrue( is_object(
$res ),
'query failed' );
197 $row =
$res->fetchObject();
221 'RevisionStorageTest_testFetchRevision',
227 $page->getRevision()->getId();
230 $id = $page->getRevision()->getId();
234 # note: order is unspecified
236 while ( ( $row =
$res->fetchObject() ) ) {
237 $rows[$row->rev_id] = $row;
240 $this->assertEquals( 1, count(
$rows ),
'expected exactly one revision' );
241 $this->assertArrayHasKey( $id,
$rows,
'missing revision with id ' . $id );
252 $this->assertTrue( in_array(
'rev_id', $fields ),
'missing rev_id in list of fields' );
253 $this->assertTrue( in_array(
'rev_page', $fields ),
'missing rev_page in list of fields' );
255 in_array(
'rev_timestamp', $fields ),
256 'missing rev_timestamp in list of fields'
258 $this->assertTrue( in_array(
'rev_user', $fields ),
'missing rev_user in list of fields' );
261 $this->assertTrue( in_array(
'rev_content_model', $fields ),
262 'missing rev_content_model in list of fields' );
263 $this->assertTrue( in_array(
'rev_content_format', $fields ),
264 'missing rev_content_format in list of fields' );
274 $orig = $this->
makeRevision( [
'page' => $page->getId() ] );
277 $this->assertEquals( $page->getId(),
$rev->getPage() );
285 'page' => $this->the_page->getId(),
286 'content_model' => $this->the_page->getContentModel(),
287 'text_id' => 123456789,
290 $this->assertNull(
$rev->getContent(),
291 "getContent() should return null if the revision's text blob could not be loaded." );
294 $this->assertNull(
$rev->getContent(),
295 "getContent() should return null if the revision's text blob could not be loaded." );
302 $orig = $this->
makeRevision( [
'text' =>
'hello hello.' ] );
305 $this->assertEquals(
'hello hello.',
$rev->getContent()->getNativeData() );
315 $this->markTestSkipped(
'$wgContentHandlerUseDB is disabled' );
318 $orig = $this->
makeRevision( [
'text' =>
'hello hello.',
332 $this->markTestSkipped(
'$wgContentHandlerUseDB is disabled' );
336 'text' =>
'hello hello.',
350 'RevisionStorageTest_testIsCurrent',
354 $rev1 = $page->getRevision();
356 # @todo find out if this should be true
357 # $this->assertTrue( $rev1->isCurrent() );
360 $this->assertTrue( $rev1x->isCurrent() );
362 $page->doEditContent(
366 $rev2 = $page->getRevision();
368 # @todo find out if this should be true
369 # $this->assertTrue( $rev2->isCurrent() );
372 $this->assertFalse( $rev1x->isCurrent() );
375 $this->assertTrue( $rev2x->isCurrent() );
383 'RevisionStorageTest_testGetPrevious',
384 'Lorem Ipsum testGetPrevious',
387 $rev1 = $page->getRevision();
389 $this->assertNull( $rev1->getPrevious() );
391 $page->doEditContent(
393 'second rev testGetPrevious' );
394 $rev2 = $page->getRevision();
396 $this->assertNotNull( $rev2->getPrevious() );
397 $this->assertEquals( $rev1->getId(), $rev2->getPrevious()->getId() );
405 'RevisionStorageTest_testGetNext',
406 'Lorem Ipsum testGetNext',
409 $rev1 = $page->getRevision();
411 $this->assertNull( $rev1->getNext() );
413 $page->doEditContent(
415 'second rev testGetNext'
417 $rev2 = $page->getRevision();
419 $this->assertNotNull( $rev1->getNext() );
420 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
428 'RevisionStorageTest_testNewNullRevision',
432 $orig = $page->getRevision();
437 $this->assertNotEquals( $orig->getId(),
$rev->getId(),
438 'new null revision shold have a different id from the original revision' );
439 $this->assertEquals( $orig->getTextId(),
$rev->getTextId(),
440 'new null revision shold have the same text id as the original revision' );
441 $this->assertEquals(
'some testing text',
$rev->getContent()->getNativeData() );
448 $ip =
'2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
456 $res =
$dbr->select(
'ip_changes',
'*', [
'ipc_rev_id' => $orig->getId() ] );
457 $row =
$res->fetchObject();
459 $this->assertEquals( IP::toHex( $ip ), $row->ipc_hex );
460 $this->assertEquals( $orig->getTimestamp(), $row->ipc_rev_timestamp );
466 3,
true, # actually the last edit
469 2,
true, # not the current edit, but still by
this user
472 1,
false, # edit by another
user
475 0,
false, # first edit, by
this user, but another user
edited in the mean time
484 $userA = User::newFromName(
"RevisionStorageTest_userA" );
485 $userB = User::newFromName(
"RevisionStorageTest_userB" );
487 if ( $userA->getId() === 0 ) {
488 $userA = User::createNew( $userA->getName() );
491 if ( $userB->getId() === 0 ) {
492 $userB = User::createNew( $userB->getName() );
502 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
503 $page->insertOn( $dbw );
507 'page' => $page->getId(),
509 'title' => $page->getTitle(),
510 'timestamp' =>
'20120101000000',
511 'user' => $userA->getId(),
514 'summary' =>
'edit zero'
516 $revisions[0]->insertOn( $dbw );
520 'page' => $page->getId(),
522 'title' => $page->getTitle(),
523 'timestamp' =>
'20120101000100',
524 'user' => $userA->getId(),
527 'summary' =>
'edit one'
529 $revisions[1]->insertOn( $dbw );
533 'page' => $page->getId(),
534 'title' => $page->getTitle(),
535 'timestamp' =>
'20120101000200',
536 'user' => $userB->getId(),
539 'summary' =>
'edit two'
541 $revisions[2]->insertOn( $dbw );
545 'page' => $page->getId(),
546 'title' => $page->getTitle(),
547 'timestamp' =>
'20120101000300',
548 'user' => $userA->getId(),
551 'summary' =>
'edit three'
553 $revisions[3]->insertOn( $dbw );
557 'page' => $page->getId(),
558 'title' => $page->getTitle(),
559 'timestamp' =>
'20120101000200',
560 'user' => $userA->getId(),
563 'summary' =>
'edit four'
565 $revisions[4]->insertOn( $dbw );
568 $since = $revisions[$sinceIdx]->getTimestamp();
572 $this->assertEquals( $expectedLast, $wasLast );
$wgExtraNamespaces
Additional namespaces.
$wgNamespaceContentModels
Associative array mapping namespace IDs to the name of the content model pages in that namespace shou...
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
$wgContentHandlers
Plugins for page content model handling.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Test class for Revision storage.
testGetPage()
Revision::getPage.
assertRevEquals(Revision $orig, Revision $rev=null)
testInsertOn()
Revision::insertOn.
testGetPrevious()
Revision::getPrevious.
testGetContent()
Revision::getContent.
testSelectFields()
Revision::selectFields.
testConstructFromRow()
Revision::__construct.
testIsCurrent()
Revision::isCurrent.
testNewFromId()
Revision::newFromId.
static provideUserWasLastToEdit()
testFetchRevision()
Revision::fetchRevision.
testUserWasLastToEdit( $sinceIdx, $expectedLast)
provideUserWasLastToEdit
testGetContentFormat()
Revision::getContentFormat.
__construct( $name=null, array $data=[], $dataName='')
testGetContentModel()
Revision::getContentModel.
testNewFromRow()
Revision::newFromRow.
testGetContent_failure()
Revision::getContent.
testNewFromArchiveRow()
Revision::newFromArchiveRow.
createPage( $page, $text, $model=null)
testNewNullRevision()
Revision::newNullRevision.
testGetNext()
Revision::getNext.
makeRevision( $props=null)
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
getContentFormat()
Returns the content format for this revision.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
getPage()
Get the page ID.
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
getContentModel()
Returns the content model for this revision.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
static userWasLastToEdit( $db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page.
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Represents a title within MediaWiki.
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.
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of edited
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
when a variable name is used in a function
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
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 CONTENT_FORMAT_JAVASCRIPT
const CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
you have access to all of the normal MediaWiki so you can get a DB use the cache