20 parent::__construct(
$name, $data, $dataName );
22 $this->tablesUsed = array_merge( $this->tablesUsed,
53 if ( !$this->the_page ) {
54 $this->the_page = $this->createPage(
55 'RevisionStorageTest_the_page',
61 $this->tablesUsed[] =
'archive';
80 if ( $props ===
null ) {
84 if ( !isset( $props[
'content'] ) && !isset( $props[
'text'] ) ) {
85 $props[
'text'] =
'Lorem Ipsum';
88 if ( !isset( $props[
'comment'] ) ) {
89 $props[
'comment'] =
'just a test';
92 if ( !isset( $props[
'page'] ) ) {
93 $props[
'page'] = $this->the_page->getId();
99 $rev->insertOn( $dbw );
105 if ( is_string(
$page ) ) {
106 if ( !preg_match(
'/:/',
$page ) &&
120 if (
$page->exists() ) {
121 $page->doDeleteArticle(
"done" );
131 $this->assertNotNull(
$rev,
'missing revision' );
133 $this->assertEquals( $orig->
getId(),
$rev->getId() );
134 $this->assertEquals( $orig->
getPage(),
$rev->getPage() );
136 $this->assertEquals( $orig->
getUser(),
$rev->getUser() );
139 $this->assertEquals( $orig->
getSha1(),
$rev->getSha1() );
149 $res =
$dbr->select(
'revision',
'*', [
'rev_id' => $orig->getId() ] );
150 $this->assertTrue( is_object(
$res ),
'query failed' );
152 $row =
$res->fetchObject();
167 $res =
$dbr->select(
'revision',
'*', [
'rev_id' => $orig->getId() ] );
168 $this->assertTrue( is_object(
$res ),
'query failed' );
170 $row =
$res->fetchObject();
183 'RevisionStorageTest_testNewFromArchiveRow',
187 $orig =
$page->getRevision();
188 $page->doDeleteArticle(
'test Revision::newFromArchiveRow' );
191 $res =
$dbr->select(
'archive',
'*', [
'ar_rev_id' => $orig->getId() ] );
192 $this->assertTrue( is_object(
$res ),
'query failed' );
194 $row =
$res->fetchObject();
218 'RevisionStorageTest_testFetchRevision',
224 $page->getRevision()->getId();
227 $id =
$page->getRevision()->getId();
231 # note: order is unspecified
233 while ( ( $row =
$res->fetchObject() ) ) {
234 $rows[$row->rev_id] = $row;
237 $this->assertEquals( 1, count( $rows ),
'expected exactly one revision' );
238 $this->assertArrayHasKey( $id, $rows,
'missing revision with id ' . $id );
249 $this->assertTrue( in_array(
'rev_id', $fields ),
'missing rev_id in list of fields' );
250 $this->assertTrue( in_array(
'rev_page', $fields ),
'missing rev_page in list of fields' );
252 in_array(
'rev_timestamp', $fields ),
253 'missing rev_timestamp in list of fields'
255 $this->assertTrue( in_array(
'rev_user', $fields ),
'missing rev_user in list of fields' );
258 $this->assertTrue( in_array(
'rev_content_model', $fields ),
259 'missing rev_content_model in list of fields' );
260 $this->assertTrue( in_array(
'rev_content_format', $fields ),
261 'missing rev_content_format in list of fields' );
274 $this->assertEquals(
$page->getId(),
$rev->getPage() );
283 $orig = $this->
makeRevision( [
'text' =>
'hello hello.' ] );
286 $this->assertEquals(
'hello hello.',
$rev->getText() );
294 'page' => $this->the_page->getId(),
295 'content_model' => $this->the_page->getContentModel(),
296 'text_id' => 123456789,
299 $this->assertNull(
$rev->getContent(),
300 "getContent() should return null if the revision's text blob could not be loaded." );
303 $this->assertNull(
$rev->getContent(),
304 "getContent() should return null if the revision's text blob could not be loaded." );
311 $orig = $this->
makeRevision( [
'text' =>
'hello hello.' ] );
314 $this->assertEquals(
'hello hello.',
$rev->getContent()->getNativeData() );
324 $this->markTestSkipped(
'$wgContentHandlerUseDB is disabled' );
327 $orig = $this->
makeRevision( [
'text' =>
'hello hello.',
341 $this->markTestSkipped(
'$wgContentHandlerUseDB is disabled' );
345 'text' =>
'hello hello.',
359 'RevisionStorageTest_testIsCurrent',
363 $rev1 =
$page->getRevision();
365 # @todo find out if this should be true
366 # $this->assertTrue( $rev1->isCurrent() );
369 $this->assertTrue( $rev1x->isCurrent() );
371 $page->doEditContent(
375 $rev2 =
$page->getRevision();
377 # @todo find out if this should be true
378 # $this->assertTrue( $rev2->isCurrent() );
381 $this->assertFalse( $rev1x->isCurrent() );
384 $this->assertTrue( $rev2x->isCurrent() );
392 'RevisionStorageTest_testGetPrevious',
393 'Lorem Ipsum testGetPrevious',
396 $rev1 =
$page->getRevision();
398 $this->assertNull( $rev1->getPrevious() );
400 $page->doEditContent(
402 'second rev testGetPrevious' );
403 $rev2 =
$page->getRevision();
405 $this->assertNotNull( $rev2->getPrevious() );
406 $this->assertEquals( $rev1->getId(), $rev2->getPrevious()->getId() );
414 'RevisionStorageTest_testGetNext',
415 'Lorem Ipsum testGetNext',
418 $rev1 =
$page->getRevision();
420 $this->assertNull( $rev1->getNext() );
422 $page->doEditContent(
424 'second rev testGetNext'
426 $rev2 =
$page->getRevision();
428 $this->assertNotNull( $rev1->getNext() );
429 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
437 'RevisionStorageTest_testNewNullRevision',
441 $orig =
$page->getRevision();
446 $this->assertNotEquals( $orig->getId(),
$rev->getId(),
447 'new null revision shold have a different id from the original revision' );
448 $this->assertEquals( $orig->getTextId(),
$rev->getTextId(),
449 'new null revision shold have the same text id as the original revision' );
450 $this->assertEquals(
'some testing text',
$rev->getContent()->getNativeData() );
456 3,
true, # actually
the last edit
459 2,
true, # not
the current edit, but still
by this user
462 1,
false, # edit
by another
user
474 $userA = User::newFromName(
"RevisionStorageTest_userA" );
475 $userB = User::newFromName(
"RevisionStorageTest_userB" );
477 if ( $userA->getId() === 0 ) {
478 $userA = User::createNew( $userA->getName() );
481 if ( $userB->getId() === 0 ) {
482 $userB = User::createNew( $userB->getName() );
492 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
493 $page->insertOn( $dbw );
497 'page' =>
$page->getId(),
499 'title' =>
$page->getTitle(),
500 'timestamp' =>
'20120101000000',
501 'user' => $userA->getId(),
504 'summary' =>
'edit zero'
506 $revisions[0]->insertOn( $dbw );
510 'page' =>
$page->getId(),
512 'title' =>
$page->getTitle(),
513 'timestamp' =>
'20120101000100',
514 'user' => $userA->getId(),
517 'summary' =>
'edit one'
519 $revisions[1]->insertOn( $dbw );
523 'page' =>
$page->getId(),
524 'title' =>
$page->getTitle(),
525 'timestamp' =>
'20120101000200',
526 'user' => $userB->getId(),
529 'summary' =>
'edit two'
531 $revisions[2]->insertOn( $dbw );
535 'page' =>
$page->getId(),
536 'title' =>
$page->getTitle(),
537 'timestamp' =>
'20120101000300',
538 'user' => $userA->getId(),
541 'summary' =>
'edit three'
543 $revisions[3]->insertOn( $dbw );
547 'page' =>
$page->getId(),
548 'title' =>
$page->getTitle(),
549 'timestamp' =>
'20120101000200',
550 'user' => $userA->getId(),
553 'summary' =>
'edit four'
555 $revisions[4]->insertOn( $dbw );
558 $since = $revisions[$sinceIdx]->getTimestamp();
562 $this->assertEquals( $expectedLast, $wasLast );
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
$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.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
Test class for Revision storage.
testGetPage()
Revision::getPage.
testGetText()
Revision::getText.
assertRevEquals(Revision $orig, Revision $rev=null)
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)
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( $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.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
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
when a variable name is used in a it is silently declared as a new local masking the global
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.
const CONTENT_FORMAT_JAVASCRIPT
const CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
the array() calling protocol came about after MediaWiki 1.4rc1.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
null for the local wiki Added in
Allows to change the fields on the form that will be generated $name
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
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
you have access to all of the normal MediaWiki so you can get a DB use the cache
#define the
table suitable for use with IDatabase::select()