20 parent::__construct(
$name, $data, $dataName );
22 $this->tablesUsed = array_merge( $this->tablesUsed,
45 $wgExtraNamespaces[12312] =
'Dummy';
46 $wgExtraNamespaces[12313] =
'Dummy_talk';
48 $wgNamespaceContentModels[12312] =
'DUMMY';
49 $wgContentHandlers[
'DUMMY'] =
'DummyContentHandlerForTesting';
52 $wgContLang->resetNamespaces(); # reset
namespace cache
53 if ( !$this->the_page ) {
55 'RevisionStorageTest_the_page',
61 $this->tablesUsed[] =
'archive';
69 unset( $wgExtraNamespaces[12312] );
70 unset( $wgExtraNamespaces[12313] );
72 unset( $wgNamespaceContentModels[12312] );
73 unset( $wgContentHandlers[
'DUMMY'] );
76 $wgContLang->resetNamespaces(); # reset
namespace cache
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 );
245 global $wgContentHandlerUseDB;
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' );
257 if ( $wgContentHandlerUseDB ) {
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() );
321 global $wgContentHandlerUseDB;
323 if ( !$wgContentHandlerUseDB ) {
324 $this->markTestSkipped(
'$wgContentHandlerUseDB is disabled' );
327 $orig = $this->
makeRevision( [
'text' =>
'hello hello.',
338 global $wgContentHandlerUseDB;
340 if ( !$wgContentHandlerUseDB ) {
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
462 1,
false, # edit
by another
user
477 if ( $userA->getId() === 0 ) {
481 if ( $userB->getId() === 0 ) {
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'
510 'page' =>
$page->getId(),
512 'title' =>
$page->getTitle(),
513 'timestamp' =>
'20120101000100',
514 'user' => $userA->getId(),
517 'summary' =>
'edit one'
523 'page' =>
$page->getId(),
524 'title' =>
$page->getTitle(),
525 'timestamp' =>
'20120101000200',
526 'user' => $userB->getId(),
529 'summary' =>
'edit two'
535 'page' =>
$page->getId(),
536 'title' =>
$page->getTitle(),
537 'timestamp' =>
'20120101000300',
538 'user' => $userA->getId(),
541 'summary' =>
'edit three'
547 'page' =>
$page->getId(),
548 'title' =>
$page->getTitle(),
549 'timestamp' =>
'20120101000200',
550 'user' => $userA->getId(),
553 'summary' =>
'edit four'
558 $since = $revisions[$sinceIdx]->getTimestamp();
562 $this->assertEquals( $expectedLast, $wasLast );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
testGetContentFormat()
Revision::getContentFormat.
#define the
table suitable for use with IDatabase::select()
testGetContent()
Revision::getContent.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
the array() calling protocol came about after MediaWiki 1.4rc1.
const CONTENT_MODEL_WIKITEXT
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn...
Test class for Revision storage.
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
getPage()
Get the page ID.
processing should stop and the error should be shown to the user * false
createPage($page, $text, $model=null)
null for the local wiki Added in
testGetContentModel()
Revision::getContentModel.
testNewFromArchiveRow()
Revision::newFromArchiveRow.
testGetNext()
Revision::getNext.
static createNew($name, $params=[])
Add a user to the database, return the user object.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testConstructFromRow()
Revision::__construct.
when a variable name is used in a it is silently declared as a new local masking the global
testGetPrevious()
Revision::getPrevious.
when a variable name is used in a function
testSelectFields()
Revision::selectFields.
testUserWasLastToEdit($sinceIdx, $expectedLast)
provideUserWasLastToEdit
you have access to all of the normal MediaWiki so you can get a DB use the cache
__construct($name=null, array $data=[], $dataName= '')
static getCanonicalName($index)
Returns the canonical (English) name for a given index.
static newNullRevision($dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
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.
testGetText()
Revision::getText.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
testIsCurrent()
Revision::isCurrent.
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
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
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
Content object for wiki text pages.
assertRevEquals(Revision $orig, Revision $rev=null)
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 as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive false for true for descending in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. 'CustomEditor'$rcid is used in generating this variable which contains information about the new such as the revision s whether the revision was marked as a minor edit or not
getContentModel()
Returns the content model for this revision.
CONTENT_MODEL_JAVASCRIPT
Uploads have to be specially set up to be secure.
testNewNullRevision()
Revision::newNullRevision.
testGetPage()
Revision::getPage.
Class representing a MediaWiki article and history.
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
$wgExtraNamespaces
Additional namespaces.
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
insertOn($dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
makeRevision($props=null)
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
$wgContentHandlers
Plugins for page content model handling.
static provideUserWasLastToEdit()
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
const CONTENT_FORMAT_JAVASCRIPT
getUser($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
testFetchRevision()
Revision::fetchRevision.
static userWasLastToEdit($db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page...
getContentFormat()
Returns the content format for this revision.
static newFromArchiveRow($row, $overrides=[])
Make a fake revision object from an archive table row.
testGetContent_failure()
Revision::getContent.
testNewFromId()
Revision::newFromId.
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
testNewFromRow()
Revision::newFromRow.
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
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
Allows to change the fields on the form that will be generated $name