Go to the documentation of this file.
20 parent::__construct(
$name, $data, $dataName );
22 $this->tablesUsed = array_merge( $this->tablesUsed,
54 if ( !$this->the_page ) {
56 'RevisionStorageTest_the_page',
62 $this->tablesUsed[] =
'archive';
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 ) &&
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
487 if ( $userA->getId() === 0 ) {
491 if ( $userB->getId() === 0 ) {
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'
520 'page' => $page->getId(),
522 'title' => $page->getTitle(),
523 'timestamp' =>
'20120101000100',
524 'user' => $userA->getId(),
527 'summary' =>
'edit one'
533 'page' => $page->getId(),
534 'title' => $page->getTitle(),
535 'timestamp' =>
'20120101000200',
536 'user' => $userB->getId(),
539 'summary' =>
'edit two'
545 'page' => $page->getId(),
546 'title' => $page->getTitle(),
547 'timestamp' =>
'20120101000300',
548 'user' => $userA->getId(),
551 'summary' =>
'edit three'
557 'page' => $page->getId(),
558 'title' => $page->getTitle(),
559 'timestamp' =>
'20120101000200',
560 'user' => $userA->getId(),
563 'summary' =>
'edit four'
568 $since = $revisions[$sinceIdx]->getTimestamp();
572 $this->assertEquals( $expectedLast, $wasLast );
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
when a variable name is used in a function
__construct( $name=null, array $data=[], $dataName='')
static toHex( $ip)
Return a zero-padded upper case hexadecimal representation of an IP address.
testNewFromRow()
Revision::newFromRow.
$wgNamespaceContentModels
Associative array mapping namespace IDs to the name of the content model pages in that namespace shou...
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testInsertOn()
Revision::insertOn.
processing should stop and the error should be shown to the user * false
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
testNewNullRevision()
Revision::newNullRevision.
getPage()
Get the page ID.
createPage( $page, $text, $model=null)
Class representing a MediaWiki article and history.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Allows to change the fields on the form that will be generated $name
const CONTENT_MODEL_WIKITEXT
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
getContentModel()
Returns the content model for this revision.
testUserWasLastToEdit( $sinceIdx, $expectedLast)
provideUserWasLastToEdit
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
you have access to all of the normal MediaWiki so you can get a DB use the cache
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
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
static createNew( $name, $params=[])
Add a user to the database, return the user object.
testConstructFromRow()
Revision::__construct.
testIsCurrent()
Revision::isCurrent.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
$wgContentHandlers
Plugins for page content model handling.
testNewFromId()
Revision::newFromId.
static provideUserWasLastToEdit()
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
testGetContent_failure()
Revision::getContent.
null for the wiki Added in
testGetContentFormat()
Revision::getContentFormat.
when a variable name is used in a it is silently declared as a new masking the global
Content object for wiki text pages.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed by
testNewFromArchiveRow()
Revision::newFromArchiveRow.
testSelectFields()
Revision::selectFields.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
testGetPage()
Revision::getPage.
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 selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
testFetchRevision()
Revision::fetchRevision.
assertRevEquals(Revision $orig, Revision $rev=null)
testGetPrevious()
Revision::getPrevious.
getContentFormat()
Returns the content format for this revision.
makeRevision( $props=null)
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
testGetContentModel()
Revision::getContentModel.
Represents a title within MediaWiki.
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
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
const CONTENT_MODEL_JAVASCRIPT
const CONTENT_FORMAT_JAVASCRIPT
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
testGetContent()
Revision::getContent.
testGetNext()
Revision::getNext.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
$wgExtraNamespaces
Additional namespaces.
Test class for Revision storage.
the array() calling protocol came about after MediaWiki 1.4rc1.
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 content language as $wgContLang