Merge "Passing the undid revisionId from the API request to the WebRequest"
[lhc/web/wiklou.git] / includes / api / ApiEditPage.php
1 <?php
2 /**
3 *
4 *
5 * Created on August 16, 2007
6 *
7 * Copyright © 2007 Iker Labarga "<Firstname><Lastname>@gmail.com"
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * A module that allows for editing and creating pages.
29 *
30 * Currently, this wraps around the EditPage class in an ugly way,
31 * EditPage.php should be rewritten to provide a cleaner interface
32 * @ingroup API
33 */
34 class ApiEditPage extends ApiBase {
35
36 public function __construct( $query, $moduleName ) {
37 parent::__construct( $query, $moduleName );
38 }
39
40 public function execute() {
41 $user = $this->getUser();
42 $params = $this->extractRequestParams();
43
44 if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) &&
45 is_null( $params['prependtext'] ) &&
46 $params['undo'] == 0 )
47 {
48 $this->dieUsageMsg( 'missingtext' );
49 }
50
51 $pageObj = $this->getTitleOrPageId( $params );
52 $titleObj = $pageObj->getTitle();
53 if ( $titleObj->isExternal() ) {
54 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
55 }
56
57 if ( !isset( $params['contentmodel'] ) || $params['contentmodel'] == '' ) {
58 $contentHandler = $pageObj->getContentHandler();
59 } else {
60 $contentHandler = ContentHandler::getForModelID( $params['contentmodel'] );
61 }
62
63 // @todo ask handler whether direct editing is supported at all! make allowFlatEdit() method or some such
64
65 if ( !isset( $params['contentformat'] ) || $params['contentformat'] == '' ) {
66 $params['contentformat'] = $contentHandler->getDefaultFormat();
67 }
68
69 $contentFormat = $params['contentformat'];
70
71 if ( !$contentHandler->isSupportedFormat( $contentFormat ) ) {
72 $name = $titleObj->getPrefixedDBkey();
73 $model = $contentHandler->getModelID();
74
75 $this->dieUsage( "The requested format $contentFormat is not supported for content model ".
76 " $model used by $name", 'badformat' );
77 }
78
79 $apiResult = $this->getResult();
80
81 if ( $params['redirect'] ) {
82 if ( $titleObj->isRedirect() ) {
83 $oldTitle = $titleObj;
84
85 $titles = Revision::newFromTitle( $oldTitle, false, Revision::READ_LATEST )
86 ->getContent( Revision::FOR_THIS_USER, $user )
87 ->getRedirectChain();
88 // array_shift( $titles );
89
90 $redirValues = array();
91 foreach ( $titles as $id => $newTitle ) {
92
93 if ( !isset( $titles[ $id - 1 ] ) ) {
94 $titles[ $id - 1 ] = $oldTitle;
95 }
96
97 $redirValues[] = array(
98 'from' => $titles[ $id - 1 ]->getPrefixedText(),
99 'to' => $newTitle->getPrefixedText()
100 );
101
102 $titleObj = $newTitle;
103 }
104
105 $apiResult->setIndexedTagName( $redirValues, 'r' );
106 $apiResult->addValue( null, 'redirects', $redirValues );
107 }
108 }
109
110 if ( $params['createonly'] && $titleObj->exists() ) {
111 $this->dieUsageMsg( 'createonly-exists' );
112 }
113 if ( $params['nocreate'] && !$titleObj->exists() ) {
114 $this->dieUsageMsg( 'nocreate-missing' );
115 }
116
117 // Now let's check whether we're even allowed to do this
118 $errors = $titleObj->getUserPermissionsErrors( 'edit', $user );
119 if ( !$titleObj->exists() ) {
120 $errors = array_merge( $errors, $titleObj->getUserPermissionsErrors( 'create', $user ) );
121 }
122 if ( count( $errors ) ) {
123 $this->dieUsageMsg( $errors[0] );
124 }
125
126 $toMD5 = $params['text'];
127 if ( !is_null( $params['appendtext'] ) || !is_null( $params['prependtext'] ) )
128 {
129 $content = $pageObj->getContent();
130
131 if ( !$content ) {
132 if ( $titleObj->getNamespace() == NS_MEDIAWIKI ) {
133 # If this is a MediaWiki:x message, then load the messages
134 # and return the message value for x.
135 $text = $titleObj->getDefaultMessageText();
136 if ( $text === false ) {
137 $text = '';
138 }
139
140 try {
141 $content = ContentHandler::makeContent( $text, $this->getTitle() );
142 } catch ( MWContentSerializationException $ex ) {
143 $this->dieUsage( $ex->getMessage(), 'parseerror' );
144 return;
145 }
146 } else {
147 # Otherwise, make a new empty content.
148 $content = $contentHandler->makeEmptyContent();
149 }
150 }
151
152 // @todo: Add support for appending/prepending to the Content interface
153
154 if ( !( $content instanceof TextContent ) ) {
155 $mode = $contentHandler->getModelID();
156 $this->dieUsage( "Can't append to pages using content model $mode", 'appendnotsupported' );
157 }
158
159 if ( !is_null( $params['section'] ) ) {
160 if ( !$contentHandler->supportsSections() ) {
161 $modelName = $contentHandler->getModelID();
162 $this->dieUsage( "Sections are not supported for this content model: $modelName.", 'sectionsnotsupported' );
163 }
164
165 // Process the content for section edits
166 $section = intval( $params['section'] );
167 $content = $content->getSection( $section );
168
169 if ( !$content ) {
170 $this->dieUsage( "There is no section {$section}.", 'nosuchsection' );
171 }
172 }
173
174 if ( !$content ) {
175 $text = '';
176 } else {
177 $text = $content->serialize( $contentFormat );
178 }
179
180 $params['text'] = $params['prependtext'] . $text . $params['appendtext'];
181 $toMD5 = $params['prependtext'] . $params['appendtext'];
182 }
183
184 if ( $params['undo'] > 0 ) {
185 if ( $params['undoafter'] > 0 ) {
186 if ( $params['undo'] < $params['undoafter'] ) {
187 list( $params['undo'], $params['undoafter'] ) =
188 array( $params['undoafter'], $params['undo'] );
189 }
190 $undoafterRev = Revision::newFromID( $params['undoafter'] );
191 }
192 $undoRev = Revision::newFromID( $params['undo'] );
193 if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
194 $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) );
195 }
196
197 if ( $params['undoafter'] == 0 ) {
198 $undoafterRev = $undoRev->getPrevious();
199 }
200 if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
201 $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) );
202 }
203
204 if ( $undoRev->getPage() != $pageObj->getID() ) {
205 $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText() ) );
206 }
207 if ( $undoafterRev->getPage() != $pageObj->getID() ) {
208 $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText() ) );
209 }
210
211 $newContent = $contentHandler->getUndoContent( $pageObj->getRevision(), $undoRev, $undoafterRev );
212
213 if ( !$newContent ) {
214 $this->dieUsageMsg( 'undo-failure' );
215 }
216
217 $params['text'] = $newContent->serialize( $params['contentformat'] );
218
219 // If no summary was given and we only undid one rev,
220 // use an autosummary
221 if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) {
222 $params['summary'] = wfMessage( 'undo-summary', $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
223 }
224 }
225
226 // See if the MD5 hash checks out
227 if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] ) {
228 $this->dieUsageMsg( 'hashcheckfailed' );
229 }
230
231 // EditPage wants to parse its stuff from a WebRequest
232 // That interface kind of sucks, but it's workable
233 $requestArray = array(
234 'wpTextbox1' => $params['text'],
235 'format' => $contentFormat,
236 'model' => $contentHandler->getModelID(),
237 'wpEditToken' => $params['token'],
238 'wpIgnoreBlankSummary' => ''
239 );
240
241 if ( !is_null( $params['summary'] ) ) {
242 $requestArray['wpSummary'] = $params['summary'];
243 }
244
245 if ( !is_null( $params['sectiontitle'] ) ) {
246 $requestArray['wpSectionTitle'] = $params['sectiontitle'];
247 }
248
249 // TODO: Pass along information from 'undoafter' as well
250 if ( $params['undo'] > 0 ) {
251 $requestArray['wpUndidRevision'] = $params['undo'];
252 }
253
254 // Watch out for basetimestamp == ''
255 // wfTimestamp() treats it as NOW, almost certainly causing an edit conflict
256 if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) {
257 $requestArray['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] );
258 } else {
259 $requestArray['wpEdittime'] = $pageObj->getTimestamp();
260 }
261
262 if ( !is_null( $params['starttimestamp'] ) && $params['starttimestamp'] != '' ) {
263 $requestArray['wpStarttime'] = wfTimestamp( TS_MW, $params['starttimestamp'] );
264 } else {
265 $requestArray['wpStarttime'] = wfTimestampNow(); // Fake wpStartime
266 }
267
268 if ( $params['minor'] || ( !$params['notminor'] && $user->getOption( 'minordefault' ) ) ) {
269 $requestArray['wpMinoredit'] = '';
270 }
271
272 if ( $params['recreate'] ) {
273 $requestArray['wpRecreate'] = '';
274 }
275
276 if ( !is_null( $params['section'] ) ) {
277 $section = intval( $params['section'] );
278 if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) {
279 $this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" );
280 }
281 $requestArray['wpSection'] = $params['section'];
282 } else {
283 $requestArray['wpSection'] = '';
284 }
285
286 $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
287
288 // Deprecated parameters
289 if ( $params['watch'] ) {
290 $watch = true;
291 } elseif ( $params['unwatch'] ) {
292 $watch = false;
293 }
294
295 if ( $watch ) {
296 $requestArray['wpWatchthis'] = '';
297 }
298
299 global $wgTitle, $wgRequest;
300
301 $req = new DerivativeRequest( $this->getRequest(), $requestArray, true );
302
303 // Some functions depend on $wgTitle == $ep->mTitle
304 // TODO: Make them not or check if they still do
305 $wgTitle = $titleObj;
306
307 $articleObject = new Article( $titleObj );
308 $ep = new EditPage( $articleObject );
309
310 // allow editing of non-textual content.
311 $ep->allowNonTextContent = true;
312
313 $ep->setContextTitle( $titleObj );
314 $ep->importFormData( $req );
315
316 // Run hooks
317 // Handle APIEditBeforeSave parameters
318 $r = array();
319 if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) {
320 if ( count( $r ) ) {
321 $r['result'] = 'Failure';
322 $apiResult->addValue( null, $this->getModuleName(), $r );
323 return;
324 } else {
325 $this->dieUsageMsg( 'hookaborted' );
326 }
327 }
328
329 // Do the actual save
330 $oldRevId = $articleObject->getRevIdFetched();
331 $result = null;
332 // Fake $wgRequest for some hooks inside EditPage
333 // @todo FIXME: This interface SUCKS
334 $oldRequest = $wgRequest;
335 $wgRequest = $req;
336
337 $status = $ep->internalAttemptSave( $result, $user->isAllowed( 'bot' ) && $params['bot'] );
338 $wgRequest = $oldRequest;
339 global $wgMaxArticleSize;
340
341 switch( $status->value ) {
342 case EditPage::AS_HOOK_ERROR:
343 case EditPage::AS_HOOK_ERROR_EXPECTED:
344 $this->dieUsageMsg( 'hookaborted' );
345
346 case EditPage::AS_PARSE_ERROR:
347 $this->dieUsage( $status->getMessage(), 'parseerror' );
348
349 case EditPage::AS_IMAGE_REDIRECT_ANON:
350 $this->dieUsageMsg( 'noimageredirect-anon' );
351
352 case EditPage::AS_IMAGE_REDIRECT_LOGGED:
353 $this->dieUsageMsg( 'noimageredirect-logged' );
354
355 case EditPage::AS_SPAM_ERROR:
356 $this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) );
357
358 case EditPage::AS_BLOCKED_PAGE_FOR_USER:
359 $this->dieUsageMsg( 'blockedtext' );
360
361 case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
362 case EditPage::AS_CONTENT_TOO_BIG:
363 $this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
364
365 case EditPage::AS_READ_ONLY_PAGE_ANON:
366 $this->dieUsageMsg( 'noedit-anon' );
367
368 case EditPage::AS_READ_ONLY_PAGE_LOGGED:
369 $this->dieUsageMsg( 'noedit' );
370
371 case EditPage::AS_READ_ONLY_PAGE:
372 $this->dieReadOnly();
373
374 case EditPage::AS_RATE_LIMITED:
375 $this->dieUsageMsg( 'actionthrottledtext' );
376
377 case EditPage::AS_ARTICLE_WAS_DELETED:
378 $this->dieUsageMsg( 'wasdeleted' );
379
380 case EditPage::AS_NO_CREATE_PERMISSION:
381 $this->dieUsageMsg( 'nocreate-loggedin' );
382
383 case EditPage::AS_BLANK_ARTICLE:
384 $this->dieUsageMsg( 'blankpage' );
385
386 case EditPage::AS_CONFLICT_DETECTED:
387 $this->dieUsageMsg( 'editconflict' );
388
389 // case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
390 case EditPage::AS_TEXTBOX_EMPTY:
391 $this->dieUsageMsg( 'emptynewsection' );
392
393 case EditPage::AS_SUCCESS_NEW_ARTICLE:
394 $r['new'] = '';
395
396 case EditPage::AS_SUCCESS_UPDATE:
397 $r['result'] = 'Success';
398 $r['pageid'] = intval( $titleObj->getArticleID() );
399 $r['title'] = $titleObj->getPrefixedText();
400 $r['contentmodel'] = $titleObj->getContentModel();
401 $newRevId = $articleObject->getLatest();
402 if ( $newRevId == $oldRevId ) {
403 $r['nochange'] = '';
404 } else {
405 $r['oldrevid'] = intval( $oldRevId );
406 $r['newrevid'] = intval( $newRevId );
407 $r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
408 $pageObj->getTimestamp() );
409 }
410 break;
411
412 case EditPage::AS_SUMMARY_NEEDED:
413 $this->dieUsageMsg( 'summaryrequired' );
414
415 case EditPage::AS_END:
416 default:
417 // $status came from WikiPage::doEdit()
418 $errors = $status->getErrorsArray();
419 $this->dieUsageMsg( $errors[0] ); // TODO: Add new errors to message map
420 break;
421 }
422 $apiResult->addValue( null, $this->getModuleName(), $r );
423 }
424
425 public function mustBePosted() {
426 return true;
427 }
428
429 public function isWriteMode() {
430 return true;
431 }
432
433 public function getDescription() {
434 return 'Create and edit pages.';
435 }
436
437 public function getPossibleErrors() {
438 global $wgMaxArticleSize;
439
440 return array_merge( parent::getPossibleErrors(),
441 $this->getTitleOrPageIdErrorMessage(),
442 array(
443 array( 'missingtext' ),
444 array( 'createonly-exists' ),
445 array( 'nocreate-missing' ),
446 array( 'nosuchrevid', 'undo' ),
447 array( 'nosuchrevid', 'undoafter' ),
448 array( 'revwrongpage', 'id', 'text' ),
449 array( 'undo-failure' ),
450 array( 'hashcheckfailed' ),
451 array( 'hookaborted' ),
452 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
453 array( 'noimageredirect-anon' ),
454 array( 'noimageredirect-logged' ),
455 array( 'spamdetected', 'spam' ),
456 array( 'summaryrequired' ),
457 array( 'blockedtext' ),
458 array( 'contenttoobig', $wgMaxArticleSize ),
459 array( 'noedit-anon' ),
460 array( 'noedit' ),
461 array( 'actionthrottledtext' ),
462 array( 'wasdeleted' ),
463 array( 'nocreate-loggedin' ),
464 array( 'blankpage' ),
465 array( 'editconflict' ),
466 array( 'emptynewsection' ),
467 array( 'unknownerror', 'retval' ),
468 array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ),
469 array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ),
470 array( 'code' => 'sectionsnotsupported', 'info' => 'Sections are not supported for this type of page.' ),
471 array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using '
472 . 'the text based edit API.' ),
473 array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending '
474 . 'or prepending text.' ),
475 array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to '
476 . 'the page\'s content model' ),
477 array( 'customcssprotected' ),
478 array( 'customjsprotected' ),
479 )
480 );
481 }
482
483 public function getAllowedParams() {
484 return array(
485 'title' => array(
486 ApiBase::PARAM_TYPE => 'string',
487 ),
488 'pageid' => array(
489 ApiBase::PARAM_TYPE => 'integer',
490 ),
491 'section' => null,
492 'sectiontitle' => array(
493 ApiBase::PARAM_TYPE => 'string',
494 ApiBase::PARAM_REQUIRED => false,
495 ),
496 'text' => null,
497 'token' => array(
498 ApiBase::PARAM_TYPE => 'string',
499 ApiBase::PARAM_REQUIRED => true
500 ),
501 'summary' => null,
502 'minor' => false,
503 'notminor' => false,
504 'bot' => false,
505 'basetimestamp' => null,
506 'starttimestamp' => null,
507 'recreate' => false,
508 'createonly' => false,
509 'nocreate' => false,
510 'watch' => array(
511 ApiBase::PARAM_DFLT => false,
512 ApiBase::PARAM_DEPRECATED => true,
513 ),
514 'unwatch' => array(
515 ApiBase::PARAM_DFLT => false,
516 ApiBase::PARAM_DEPRECATED => true,
517 ),
518 'watchlist' => array(
519 ApiBase::PARAM_DFLT => 'preferences',
520 ApiBase::PARAM_TYPE => array(
521 'watch',
522 'unwatch',
523 'preferences',
524 'nochange'
525 ),
526 ),
527 'md5' => null,
528 'prependtext' => null,
529 'appendtext' => null,
530 'undo' => array(
531 ApiBase::PARAM_TYPE => 'integer'
532 ),
533 'undoafter' => array(
534 ApiBase::PARAM_TYPE => 'integer'
535 ),
536 'redirect' => array(
537 ApiBase::PARAM_TYPE => 'boolean',
538 ApiBase::PARAM_DFLT => false,
539 ),
540 'contentformat' => array(
541 ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
542 ),
543 'contentmodel' => array(
544 ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
545 )
546 );
547 }
548
549 public function getParamDescription() {
550 $p = $this->getModulePrefix();
551 return array(
552 'title' => "Title of the page you want to edit. Cannot be used together with {$p}pageid",
553 'pageid' => "Page ID of the page you want to edit. Cannot be used together with {$p}title",
554 'section' => 'Section number. 0 for the top section, \'new\' for a new section',
555 'sectiontitle' => 'The title for a new section',
556 'text' => 'Page content',
557 'token' => array( 'Edit token. You can get one of these through prop=info.',
558 "The token should always be sent as the last parameter, or at least, after the {$p}text parameter"
559 ),
560 'summary' => "Edit summary. Also section title when {$p}section=new and {$p}sectiontitle is not set",
561 'minor' => 'Minor edit',
562 'notminor' => 'Non-minor edit',
563 'bot' => 'Mark this edit as bot',
564 'basetimestamp' => array( 'Timestamp of the base revision (obtained through prop=revisions&rvprop=timestamp).',
565 'Used to detect edit conflicts; leave unset to ignore conflicts'
566 ),
567 'starttimestamp' => array( 'Timestamp when you obtained the edit token.',
568 'Used to detect edit conflicts; leave unset to ignore conflicts'
569 ),
570 'recreate' => 'Override any errors about the article having been deleted in the meantime',
571 'createonly' => 'Don\'t edit the page if it exists already',
572 'nocreate' => 'Throw an error if the page doesn\'t exist',
573 'watch' => 'Add the page to your watchlist',
574 'unwatch' => 'Remove the page from your watchlist',
575 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
576 'md5' => array( "The MD5 hash of the {$p}text parameter, or the {$p}prependtext and {$p}appendtext parameters concatenated.",
577 'If set, the edit won\'t be done unless the hash is correct' ),
578 'prependtext' => "Add this text to the beginning of the page. Overrides {$p}text",
579 'appendtext' => array( "Add this text to the end of the page. Overrides {$p}text.",
580 "Use {$p}section=new to append a new section" ),
581 'undo' => "Undo this revision. Overrides {$p}text, {$p}prependtext and {$p}appendtext",
582 'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',
583 'redirect' => 'Automatically resolve redirects',
584 'contentformat' => 'Content serialization format used for the input text',
585 'contentmodel' => 'Content model of the new content',
586 );
587 }
588
589 public function getResultProperties() {
590 return array(
591 '' => array(
592 'new' => 'boolean',
593 'result' => array(
594 ApiBase::PROP_TYPE => array(
595 'Success',
596 'Failure'
597 ),
598 ),
599 'pageid' => array(
600 ApiBase::PROP_TYPE => 'integer',
601 ApiBase::PROP_NULLABLE => true
602 ),
603 'title' => array(
604 ApiBase::PROP_TYPE => 'string',
605 ApiBase::PROP_NULLABLE => true
606 ),
607 'nochange' => 'boolean',
608 'oldrevid' => array(
609 ApiBase::PROP_TYPE => 'integer',
610 ApiBase::PROP_NULLABLE => true
611 ),
612 'newrevid' => array(
613 ApiBase::PROP_TYPE => 'integer',
614 ApiBase::PROP_NULLABLE => true
615 ),
616 'newtimestamp' => array(
617 ApiBase::PROP_TYPE => 'string',
618 ApiBase::PROP_NULLABLE => true
619 )
620 )
621 );
622 }
623
624 public function needsToken() {
625 return true;
626 }
627
628 public function getTokenSalt() {
629 return '';
630 }
631
632 public function getExamples() {
633 return array(
634
635 'api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\'
636 => 'Edit a page (anonymous user)',
637
638 'api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
639 => 'Prepend __NOTOC__ to a page (anonymous user)',
640 'api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\'
641 => 'Undo r13579 through r13585 with autosummary (anonymous user)',
642 );
643 }
644
645 public function getHelpUrls() {
646 return 'https://www.mediawiki.org/wiki/API:Edit';
647 }
648
649 public function getVersion() {
650 return __CLASS__ . ': $Id$';
651 }
652 }