Go to the documentation of this file.
17 global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers,
$wgContLang;
22 'wgExtraNamespaces' => $wgExtraNamespaces,
23 'wgNamespaceContentModels' => $wgNamespaceContentModels,
24 'wgContentHandlers' => $wgContentHandlers,
28 $wgExtraNamespaces[12312] =
'Dummy';
29 $wgExtraNamespaces[12313] =
'Dummy_talk';
31 $wgNamespaceContentModels[12312] =
"testing";
32 $wgContentHandlers[
"testing"] =
'DummyContentHandlerForTesting';
46 $name =
'Help:ApiEditPageTest_testEdit';
52 'text' =>
'some text',
54 $apiResult = $apiResult[0];
57 $this->assertArrayHasKey(
'edit', $apiResult );
58 $this->assertArrayHasKey(
'result', $apiResult[
'edit'] );
59 $this->assertEquals(
'Success', $apiResult[
'edit'][
'result'] );
61 $this->assertArrayHasKey(
'new', $apiResult[
'edit'] );
62 $this->assertArrayNotHasKey(
'nochange', $apiResult[
'edit'] );
64 $this->assertArrayHasKey(
'pageid', $apiResult[
'edit'] );
70 'text' =>
'some text',
73 $this->assertEquals(
'Success', $data[0][
'edit'][
'result'] );
75 $this->assertArrayNotHasKey(
'new', $data[0][
'edit'] );
76 $this->assertArrayHasKey(
'nochange', $data[0][
'edit'] );
82 'text' =>
'different text'
85 $this->assertEquals(
'Success', $data[0][
'edit'][
'result'] );
87 $this->assertArrayNotHasKey(
'new', $data[0][
'edit'] );
88 $this->assertArrayNotHasKey(
'nochange', $data[0][
'edit'] );
90 $this->assertArrayHasKey(
'oldrevid', $data[0][
'edit'] );
91 $this->assertArrayHasKey(
'newrevid', $data[0][
'edit'] );
92 $this->assertNotEquals(
93 $data[0][
'edit'][
'newrevid'],
94 $data[0][
'edit'][
'oldrevid'],
95 "revision id should change after edit"
100 $name =
'Dummy:ApiEditPageTest_testNonTextEdit';
101 $data = serialize(
'some bla bla text' );
107 'text' => $data, ) );
108 $apiResult = $apiResult[0];
111 $this->assertArrayHasKey(
'edit', $apiResult );
112 $this->assertArrayHasKey(
'result', $apiResult[
'edit'] );
113 $this->assertEquals(
'Success', $apiResult[
'edit'][
'result'] );
115 $this->assertArrayHasKey(
'new', $apiResult[
'edit'] );
116 $this->assertArrayNotHasKey(
'nochange', $apiResult[
'edit'] );
118 $this->assertArrayHasKey(
'pageid', $apiResult[
'edit'] );
122 $this->assertEquals(
"testing", $page->getContentModel() );
123 $this->assertEquals( $data, $page->getContent()->serialize() );
132 'foo',
'append',
'bar',
"foobar"
135 'foo',
'prepend',
'bar',
"barfoo"
138 '',
'append',
'foo',
"foo"
141 '',
'prepend',
'foo',
"foo"
144 null,
'append',
'foo',
"foo"
147 null,
'prepend',
'foo',
"foo"
160 $name =
"Help:ApiEditPageTest_testEditAppend_$count";
163 if ( $text !==
null ) {
164 if ( $text ===
'' ) {
169 'text' =>
'(dummy)', ) );
175 'text' => $text, ) );
177 $this->assertEquals(
'Success', $re[
'edit'][
'result'] );
184 $op .
'text' => $append, ) );
186 $this->assertEquals(
'Success', $re[
'edit'][
'result'] );
190 $content = $page->getContent();
191 $this->assertNotNull( $content,
'Page should have been created' );
193 $text = $content->getNativeData();
195 $this->assertEquals( $expected, $text );
202 $name =
'Help:ApiEditPageTest_testEditSection';
204 $text =
"==section 1==\ncontent 1\n==section 2==\ncontent2";
212 'text' =>
"==section 1==\nnew content 1",
214 $this->assertEquals(
'Success', $re[
'edit'][
'result'] );
218 $this->assertEquals(
"==section 1==\nnew content 1\n\n==section 2==\ncontent2", $newtext );
228 $this->
fail(
"Should have raised a UsageException" );
230 $this->assertEquals(
'nosuchsection',
$e->getCodeString() );
241 $name =
'Help:ApiEditPageTest_testEditNewSection';
250 'summary' =>
'header',
253 $this->assertEquals(
'Success', $re[
'edit'][
'result'] );
258 $this->assertEquals(
"== header ==\n\ntest", $text );
267 'summary' =>
'header',
270 $this->assertEquals(
'Success', $re2[
'edit'][
'result'] );
274 $this->assertEquals(
"== header ==\n\ntest\n\n== header ==\n\ntest", $text );
282 $name =
"Help:ApiEditPageTest_testEditConflict_$count";
289 "testing 1",
EDIT_NEW,
false, self::$users[
'sysop']->
user );
291 $baseTime = $page->getRevision()->getTimestamp();
295 "testing 2",
EDIT_UPDATE, $page->getLatest(), self::$users[
'uploader']->user );
303 'text' =>
'nix bar!',
304 'basetimestamp' => $baseTime,
305 ),
null, self::$users[
'sysop']->
user );
307 $this->
fail(
'edit conflict expected' );
318 $name =
"Help:ApiEditPageTest_testEditConflict_redirect_$count";
322 $rname =
"Help:ApiEditPageTest_testEditConflict_redirect_r$count";
328 "testing 1",
EDIT_NEW,
false, self::$users[
'sysop']->
user );
330 $baseTime = $page->getRevision()->getTimestamp();
334 "testing 1",
EDIT_NEW,
false, self::$users[
'sysop']->
user );
338 $rpage->doEditContent(
new WikitextContent(
"#REDIRECT [[$name]]\n\n[[Category:Test]]" ),
339 "testing 2",
EDIT_UPDATE, $page->getLatest(), self::$users[
'uploader']->user );
346 'text' =>
'nix bar!',
347 'basetimestamp' => $baseTime,
349 ),
null, self::$users[
'sysop']->
user );
351 $this->assertEquals(
'Success', $re[
'edit'][
'result'],
352 "no edit conflict expected when following redirect" );
359 'text' =>
'nix bar!',
360 'basetimestamp' => $baseTime,
361 ),
null, self::$users[
'sysop']->
user );
363 $this->
fail(
'edit conflict expected' );
380 $name =
"Help:ApiEditPageTest_testEditConflict_redirect_bug41990_$count";
384 $rname =
"Help:ApiEditPageTest_testEditConflict_redirect_bug41990_r$count";
390 "testing 1",
EDIT_NEW,
false, self::$users[
'sysop']->
user );
395 "testing 1",
EDIT_NEW,
false, self::$users[
'sysop']->
user );
400 "testing 2",
EDIT_UPDATE, $page->getLatest(), self::$users[
'uploader']->user );
407 'text' =>
'nix bar!',
409 ),
null, self::$users[
'sysop']->
user );
411 $this->assertEquals(
'Success', $re[
'edit'][
'result'],
412 "no edit conflict expected here" );
422 $dbw->update(
'revision',
testEditConflict_redirect()
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
testEditAppend( $text, $op, $append, $expected)
@dataProvider provideEditAppend
Class representing a MediaWiki article and history.
static provideEditAppend()
as a message key or array as accepted by ApiBase::dieUsageMsg after processing request parameters Return false to let the request fail
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
you have access to all of the normal MediaWiki so you can get a DB use the cache
Tests for MediaWiki api.php?action=edit.
testEditSection()
Test editing of sections.
testEditConflict_bug41990()
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
This exception will be thrown when dieUsage is called to stop module execution.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
getLatest()
Get the page_latest field.
Content object for wiki text pages.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
presenting them properly to the user as errors is done by the caller $title
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
Allows to change the fields on the form that will be generated $name
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
testEditNewSection()
Test action=edit§ion=new Run it twice so we test adding a new section on a page that doesn't exis...
doApiRequestWithToken(array $params, array $session=null, User $user=null)
Add an edit token to the API request This is cheating a bit – we grab a token in the correct format a...
forceRevisionDate(WikiPage $page, $timestamp)
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 my talk page