MediaWiki  master
Go to the documentation of this file.
1 <?php
11  public function __construct( $name = null, array $data = [], $dataName = '' ) {
12  parent::__construct( $name, $data, $dataName );
14  $this->tablesUsed[] = 'revision';
15  }
21  $pageName = 'Help:' . __METHOD__;
22  $title = Title::newFromText( $pageName );
23  $page = WikiPage::factory( $title );
25  $page->doEditContent(
26  ContentHandler::makeContent( 'Some text', $page->getTitle() ),
27  'inserting content'
28  );
29  $page->doEditContent(
30  ContentHandler::makeContent( 'Some other text', $page->getTitle() ),
31  'adding revision'
32  );
34  $apiResult = $this->doApiRequest( [
35  'action' => 'query',
36  'list' => 'allrevisions',
37  'arvprop' => 'content',
38  'arvslots' => 'main',
39  'arvdir' => 'older',
40  ] );
42  $this->assertArrayHasKey( 'query', $apiResult[0] );
43  $this->assertArrayHasKey( 'allrevisions', $apiResult[0]['query'] );
44  $this->assertArrayHasKey( 0, $apiResult[0]['query']['allrevisions'] );
45  $this->assertArrayHasKey( 'title', $apiResult[0]['query']['allrevisions'][0] );
46  $this->assertSame( $pageName, $apiResult[0]['query']['allrevisions'][0]['title'] );
47  $this->assertArrayHasKey( 'revisions', $apiResult[0]['query']['allrevisions'][0] );
48  $this->assertCount( 2, $apiResult[0]['query']['allrevisions'][0]['revisions'] );
50  foreach ( $apiResult[0]['query']['allrevisions'] as $page ) {
51  $this->assertArrayHasKey( 'revisions', $page );
52  foreach ( $page['revisions'] as $revision ) {
53  $this->assertArrayHasKey( 'slots', $revision );
54  $this->assertArrayHasKey( 'main', $revision['slots'] );
55  $this->assertArrayHasKey( 'contentformat', $revision['slots']['main'],
56  'contentformat should be included when asking content so client knows how to interpret it'
57  );
58  $this->assertArrayHasKey( 'contentmodel', $revision['slots']['main'],
59  'contentmodel should be included when asking content so client knows how to interpret it'
60  );
61  }
62  }
63  }
64 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:138
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
Definition: ApiTestCase.php:62
__construct( $name=null, array $data=[], $dataName='')
API Database medium ApiQueryAllRevisions.
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
Definition: hooks.txt:780
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
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 as
Definition: distributors.txt:9
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
Definition: injection.txt:35
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319