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