MediaWiki REL1_27
ApiEditPage.php
Go to the documentation of this file.
1<?php
36class ApiEditPage extends ApiBase {
37 public function execute() {
39
40 $user = $this->getUser();
42
43 if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) &&
44 is_null( $params['prependtext'] ) &&
45 $params['undo'] == 0
46 ) {
47 $this->dieUsageMsg( 'missingtext' );
48 }
49
50 $pageObj = $this->getTitleOrPageId( $params );
51 $titleObj = $pageObj->getTitle();
52 $apiResult = $this->getResult();
53
54 if ( $params['redirect'] ) {
55 if ( $params['prependtext'] === null && $params['appendtext'] === null
56 && $params['section'] !== 'new'
57 ) {
58 $this->dieUsage( 'You have attempted to edit using the "redirect"-following'
59 . ' mode, which must be used in conjuction with section=new, prependtext'
60 . ', or appendtext.', 'redirect-appendonly' );
61 }
62 if ( $titleObj->isRedirect() ) {
63 $oldTitle = $titleObj;
64
66 ->getContent( Revision::FOR_THIS_USER, $user )
67 ->getRedirectChain();
68 // array_shift( $titles );
69
70 $redirValues = [];
71
73 foreach ( $titles as $id => $newTitle ) {
74
75 if ( !isset( $titles[$id - 1] ) ) {
76 $titles[$id - 1] = $oldTitle;
77 }
78
79 $redirValues[] = [
80 'from' => $titles[$id - 1]->getPrefixedText(),
81 'to' => $newTitle->getPrefixedText()
82 ];
83
84 $titleObj = $newTitle;
85 }
86
87 ApiResult::setIndexedTagName( $redirValues, 'r' );
88 $apiResult->addValue( null, 'redirects', $redirValues );
89
90 // Since the page changed, update $pageObj
91 $pageObj = WikiPage::factory( $titleObj );
92 }
93 }
94
95 if ( !isset( $params['contentmodel'] ) || $params['contentmodel'] == '' ) {
96 $contentHandler = $pageObj->getContentHandler();
97 } else {
98 $contentHandler = ContentHandler::getForModelID( $params['contentmodel'] );
99 }
100
101 $name = $titleObj->getPrefixedDBkey();
102 $model = $contentHandler->getModelID();
103
104 if ( $params['undo'] > 0 ) {
105 // allow undo via api
106 } elseif ( $contentHandler->supportsDirectApiEditing() === false ) {
107 $this->dieUsage(
108 "Direct editing via API is not supported for content model $model used by $name",
109 'no-direct-editing'
110 );
111 }
112
113 if ( !isset( $params['contentformat'] ) || $params['contentformat'] == '' ) {
114 $params['contentformat'] = $contentHandler->getDefaultFormat();
115 }
116
117 $contentFormat = $params['contentformat'];
118
119 if ( !$contentHandler->isSupportedFormat( $contentFormat ) ) {
120
121 $this->dieUsage( "The requested format $contentFormat is not supported for content model " .
122 " $model used by $name", 'badformat' );
123 }
124
125 if ( $params['createonly'] && $titleObj->exists() ) {
126 $this->dieUsageMsg( 'createonly-exists' );
127 }
128 if ( $params['nocreate'] && !$titleObj->exists() ) {
129 $this->dieUsageMsg( 'nocreate-missing' );
130 }
131
132 // Now let's check whether we're even allowed to do this
133 $errors = $titleObj->getUserPermissionsErrors( 'edit', $user );
134 if ( !$titleObj->exists() ) {
135 $errors = array_merge( $errors, $titleObj->getUserPermissionsErrors( 'create', $user ) );
136 }
137 if ( count( $errors ) ) {
138 if ( is_array( $errors[0] ) ) {
139 switch ( $errors[0][0] ) {
140 case 'blockedtext':
141 $this->dieUsage(
142 'You have been blocked from editing',
143 'blocked',
144 0,
145 [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
146 );
147 break;
148 case 'autoblockedtext':
149 $this->dieUsage(
150 'Your IP address has been blocked automatically, because it was used by a blocked user',
151 'autoblocked',
152 0,
153 [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
154 );
155 break;
156 default:
157 $this->dieUsageMsg( $errors[0] );
158 }
159 } else {
160 $this->dieUsageMsg( $errors[0] );
161 }
162 }
163
164 $toMD5 = $params['text'];
165 if ( !is_null( $params['appendtext'] ) || !is_null( $params['prependtext'] ) ) {
166 $content = $pageObj->getContent();
167
168 if ( !$content ) {
169 if ( $titleObj->getNamespace() == NS_MEDIAWIKI ) {
170 # If this is a MediaWiki:x message, then load the messages
171 # and return the message value for x.
172 $text = $titleObj->getDefaultMessageText();
173 if ( $text === false ) {
174 $text = '';
175 }
176
177 try {
178 $content = ContentHandler::makeContent( $text, $this->getTitle() );
179 } catch ( MWContentSerializationException $ex ) {
180 $this->dieUsage( $ex->getMessage(), 'parseerror' );
181
182 return;
183 }
184 } else {
185 # Otherwise, make a new empty content.
186 $content = $contentHandler->makeEmptyContent();
187 }
188 }
189
190 // @todo Add support for appending/prepending to the Content interface
191
192 if ( !( $content instanceof TextContent ) ) {
193 $mode = $contentHandler->getModelID();
194 $this->dieUsage( "Can't append to pages using content model $mode", 'appendnotsupported' );
195 }
196
197 if ( !is_null( $params['section'] ) ) {
198 if ( !$contentHandler->supportsSections() ) {
199 $modelName = $contentHandler->getModelID();
200 $this->dieUsage(
201 "Sections are not supported for this content model: $modelName.",
202 'sectionsnotsupported'
203 );
204 }
205
206 if ( $params['section'] == 'new' ) {
207 // DWIM if they're trying to prepend/append to a new section.
208 $content = null;
209 } else {
210 // Process the content for section edits
211 $section = $params['section'];
212 $content = $content->getSection( $section );
213
214 if ( !$content ) {
215 $this->dieUsage( "There is no section {$section}.", 'nosuchsection' );
216 }
217 }
218 }
219
220 if ( !$content ) {
221 $text = '';
222 } else {
223 $text = $content->serialize( $contentFormat );
224 }
225
226 $params['text'] = $params['prependtext'] . $text . $params['appendtext'];
227 $toMD5 = $params['prependtext'] . $params['appendtext'];
228 }
229
230 if ( $params['undo'] > 0 ) {
231 if ( $params['undoafter'] > 0 ) {
232 if ( $params['undo'] < $params['undoafter'] ) {
233 list( $params['undo'], $params['undoafter'] ) =
234 [ $params['undoafter'], $params['undo'] ];
235 }
236 $undoafterRev = Revision::newFromId( $params['undoafter'] );
237 }
238 $undoRev = Revision::newFromId( $params['undo'] );
239 if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
240 $this->dieUsageMsg( [ 'nosuchrevid', $params['undo'] ] );
241 }
242
243 if ( $params['undoafter'] == 0 ) {
244 $undoafterRev = $undoRev->getPrevious();
245 }
246 if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
247 $this->dieUsageMsg( [ 'nosuchrevid', $params['undoafter'] ] );
248 }
249
250 if ( $undoRev->getPage() != $pageObj->getId() ) {
251 $this->dieUsageMsg( [ 'revwrongpage', $undoRev->getId(),
252 $titleObj->getPrefixedText() ] );
253 }
254 if ( $undoafterRev->getPage() != $pageObj->getId() ) {
255 $this->dieUsageMsg( [ 'revwrongpage', $undoafterRev->getId(),
256 $titleObj->getPrefixedText() ] );
257 }
258
259 $newContent = $contentHandler->getUndoContent(
260 $pageObj->getRevision(),
261 $undoRev,
262 $undoafterRev
263 );
264
265 if ( !$newContent ) {
266 $this->dieUsageMsg( 'undo-failure' );
267 }
268
269 $params['text'] = $newContent->serialize( $params['contentformat'] );
270
271 // If no summary was given and we only undid one rev,
272 // use an autosummary
273 if ( is_null( $params['summary'] ) &&
274 $titleObj->getNextRevisionID( $undoafterRev->getId() ) == $params['undo']
275 ) {
276 $params['summary'] = wfMessage( 'undo-summary' )
277 ->params( $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
278 }
279 }
280
281 // See if the MD5 hash checks out
282 if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] ) {
283 $this->dieUsageMsg( 'hashcheckfailed' );
284 }
285
286 // EditPage wants to parse its stuff from a WebRequest
287 // That interface kind of sucks, but it's workable
288 $requestArray = [
289 'wpTextbox1' => $params['text'],
290 'format' => $contentFormat,
291 'model' => $contentHandler->getModelID(),
292 'wpEditToken' => $params['token'],
293 'wpIgnoreBlankSummary' => true,
294 'wpIgnoreBlankArticle' => true,
295 'wpIgnoreSelfRedirect' => true,
296 'bot' => $params['bot'],
297 ];
298
299 if ( !is_null( $params['summary'] ) ) {
300 $requestArray['wpSummary'] = $params['summary'];
301 }
302
303 if ( !is_null( $params['sectiontitle'] ) ) {
304 $requestArray['wpSectionTitle'] = $params['sectiontitle'];
305 }
306
307 // TODO: Pass along information from 'undoafter' as well
308 if ( $params['undo'] > 0 ) {
309 $requestArray['wpUndidRevision'] = $params['undo'];
310 }
311
312 // Watch out for basetimestamp == '' or '0'
313 // It gets treated as NOW, almost certainly causing an edit conflict
314 if ( $params['basetimestamp'] !== null && (bool)$this->getMain()->getVal( 'basetimestamp' ) ) {
315 $requestArray['wpEdittime'] = $params['basetimestamp'];
316 } else {
317 $requestArray['wpEdittime'] = $pageObj->getTimestamp();
318 }
319
320 if ( $params['starttimestamp'] !== null ) {
321 $requestArray['wpStarttime'] = $params['starttimestamp'];
322 } else {
323 $requestArray['wpStarttime'] = wfTimestampNow(); // Fake wpStartime
324 }
325
326 if ( $params['minor'] || ( !$params['notminor'] && $user->getOption( 'minordefault' ) ) ) {
327 $requestArray['wpMinoredit'] = '';
328 }
329
330 if ( $params['recreate'] ) {
331 $requestArray['wpRecreate'] = '';
332 }
333
334 if ( !is_null( $params['section'] ) ) {
335 $section = $params['section'];
336 if ( !preg_match( '/^((T-)?\d+|new)$/', $section ) ) {
337 $this->dieUsage( "The section parameter must be a valid section id or 'new'",
338 'invalidsection' );
339 }
340 $content = $pageObj->getContent();
341 if ( $section !== '0' && $section != 'new'
342 && ( !$content || !$content->getSection( $section ) )
343 ) {
344 $this->dieUsage( "There is no section {$section}.", 'nosuchsection' );
345 }
346 $requestArray['wpSection'] = $params['section'];
347 } else {
348 $requestArray['wpSection'] = '';
349 }
350
351 $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
352
353 // Deprecated parameters
354 if ( $params['watch'] ) {
355 $watch = true;
356 } elseif ( $params['unwatch'] ) {
357 $watch = false;
358 }
359
360 if ( $watch ) {
361 $requestArray['wpWatchthis'] = '';
362 }
363
364 // Apply change tags
365 if ( count( $params['tags'] ) ) {
367 if ( $tagStatus->isOK() ) {
368 $requestArray['wpChangeTags'] = implode( ',', $params['tags'] );
369 } else {
370 $this->dieStatus( $tagStatus );
371 }
372 }
373
374 // Pass through anything else we might have been given, to support extensions
375 // This is kind of a hack but it's the best we can do to make extensions work
376 $requestArray += $this->getRequest()->getValues();
377
379
380 $req = new DerivativeRequest( $this->getRequest(), $requestArray, true );
381
382 // Some functions depend on $wgTitle == $ep->mTitle
383 // TODO: Make them not or check if they still do
384 $wgTitle = $titleObj;
385
386 $articleContext = new RequestContext;
387 $articleContext->setRequest( $req );
388 $articleContext->setWikiPage( $pageObj );
389 $articleContext->setUser( $this->getUser() );
390
392 $articleObject = Article::newFromWikiPage( $pageObj, $articleContext );
393
394 $ep = new EditPage( $articleObject );
395
396 $ep->setApiEditOverride( true );
397 $ep->setContextTitle( $titleObj );
398 $ep->importFormData( $req );
399 $content = $ep->textbox1;
400
401 // Run hooks
402 // Handle APIEditBeforeSave parameters
403 $r = [];
404 if ( !Hooks::run( 'APIEditBeforeSave', [ $ep, $content, &$r ] ) ) {
405 if ( count( $r ) ) {
406 $r['result'] = 'Failure';
407 $apiResult->addValue( null, $this->getModuleName(), $r );
408
409 return;
410 }
411
412 $this->dieUsageMsg( 'hookaborted' );
413 }
414
415 // Do the actual save
416 $oldRevId = $articleObject->getRevIdFetched();
417 $result = null;
418 // Fake $wgRequest for some hooks inside EditPage
419 // @todo FIXME: This interface SUCKS
420 $oldRequest = $wgRequest;
422
423 $status = $ep->attemptSave( $result );
424 $wgRequest = $oldRequest;
425
426 switch ( $status->value ) {
429 if ( isset( $status->apiHookResult ) ) {
430 $r = $status->apiHookResult;
431 $r['result'] = 'Failure';
432 $apiResult->addValue( null, $this->getModuleName(), $r );
433 return;
434 } else {
435 $this->dieUsageMsg( 'hookaborted' );
436 }
437
439 $this->dieUsage( $status->getMessage(), 'parseerror' );
440
442 $this->dieUsageMsg( 'noimageredirect-anon' );
443
445 $this->dieUsageMsg( 'noimageredirect-logged' );
446
448 $this->dieUsageMsg( [ 'spamdetected', $result['spam'] ] );
449
451 $this->dieUsage(
452 'You have been blocked from editing',
453 'blocked',
454 0,
455 [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
456 );
457
460 $this->dieUsageMsg( [ 'contenttoobig', $this->getConfig()->get( 'MaxArticleSize' ) ] );
461
463 $this->dieUsageMsg( 'noedit-anon' );
464
466 $this->dieUsageMsg( 'noedit' );
467
469 $this->dieReadOnly();
470
472 $this->dieUsageMsg( 'actionthrottledtext' );
473
475 $this->dieUsageMsg( 'wasdeleted' );
476
478 $this->dieUsageMsg( 'nocreate-loggedin' );
479
481 $this->dieUsageMsg( 'cantchangecontentmodel' );
482
484 $this->dieUsageMsg( 'blankpage' );
485
487 $this->dieUsageMsg( 'editconflict' );
488
490 $this->dieUsageMsg( 'emptynewsection' );
491
493 $this->dieStatus( $status );
494
496 $r['new'] = true;
497 // fall-through
498
500 $r['result'] = 'Success';
501 $r['pageid'] = intval( $titleObj->getArticleID() );
502 $r['title'] = $titleObj->getPrefixedText();
503 $r['contentmodel'] = $articleObject->getContentModel();
504 $newRevId = $articleObject->getLatest();
505 if ( $newRevId == $oldRevId ) {
506 $r['nochange'] = true;
507 } else {
508 $r['oldrevid'] = intval( $oldRevId );
509 $r['newrevid'] = intval( $newRevId );
510 $r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
511 $pageObj->getTimestamp() );
512 }
513 break;
514
516 // Shouldn't happen since we set wpIgnoreBlankSummary, but just in case
517 $this->dieUsageMsg( 'summaryrequired' );
518
519 case EditPage::AS_END:
520 default:
521 // $status came from WikiPage::doEdit()
522 $errors = $status->getErrorsArray();
523 $this->dieUsageMsg( $errors[0] ); // TODO: Add new errors to message map
524 break;
525 }
526 $apiResult->addValue( null, $this->getModuleName(), $r );
527 }
528
529 public function mustBePosted() {
530 return true;
531 }
532
533 public function isWriteMode() {
534 return true;
535 }
536
537 public function getAllowedParams() {
538 return [
539 'title' => [
540 ApiBase::PARAM_TYPE => 'string',
541 ],
542 'pageid' => [
543 ApiBase::PARAM_TYPE => 'integer',
544 ],
545 'section' => null,
546 'sectiontitle' => [
547 ApiBase::PARAM_TYPE => 'string',
548 ],
549 'text' => [
550 ApiBase::PARAM_TYPE => 'text',
551 ],
552 'summary' => null,
553 'tags' => [
554 ApiBase::PARAM_TYPE => 'tags',
556 ],
557 'minor' => false,
558 'notminor' => false,
559 'bot' => false,
560 'basetimestamp' => [
561 ApiBase::PARAM_TYPE => 'timestamp',
562 ],
563 'starttimestamp' => [
564 ApiBase::PARAM_TYPE => 'timestamp',
565 ],
566 'recreate' => false,
567 'createonly' => false,
568 'nocreate' => false,
569 'watch' => [
570 ApiBase::PARAM_DFLT => false,
572 ],
573 'unwatch' => [
574 ApiBase::PARAM_DFLT => false,
576 ],
577 'watchlist' => [
578 ApiBase::PARAM_DFLT => 'preferences',
580 'watch',
581 'unwatch',
582 'preferences',
583 'nochange'
584 ],
585 ],
586 'md5' => null,
587 'prependtext' => [
588 ApiBase::PARAM_TYPE => 'text',
589 ],
590 'appendtext' => [
591 ApiBase::PARAM_TYPE => 'text',
592 ],
593 'undo' => [
594 ApiBase::PARAM_TYPE => 'integer'
595 ],
596 'undoafter' => [
597 ApiBase::PARAM_TYPE => 'integer'
598 ],
599 'redirect' => [
600 ApiBase::PARAM_TYPE => 'boolean',
601 ApiBase::PARAM_DFLT => false,
602 ],
603 'contentformat' => [
605 ],
606 'contentmodel' => [
608 ],
609 'token' => [
610 // Standard definition automatically inserted
611 ApiBase::PARAM_HELP_MSG_APPEND => [ 'apihelp-edit-param-token' ],
612 ],
613 ];
614 }
615
616 public function needsToken() {
617 return 'csrf';
618 }
619
620 protected function getExamplesMessages() {
621 return [
622 'action=edit&title=Test&summary=test%20summary&' .
623 'text=article%20content&basetimestamp=2007-08-24T12:34:54Z&token=123ABC'
624 => 'apihelp-edit-example-edit',
625 'action=edit&title=Test&summary=NOTOC&minor=&' .
626 'prependtext=__NOTOC__%0A&basetimestamp=2007-08-24T12:34:54Z&token=123ABC'
627 => 'apihelp-edit-example-prepend',
628 'action=edit&title=Test&undo=13585&undoafter=13579&' .
629 'basetimestamp=2007-08-24T12:34:54Z&token=123ABC'
630 => 'apihelp-edit-example-undo',
631 ];
632 }
633
634 public function getHelpUrls() {
635 return 'https://www.mediawiki.org/wiki/API:Edit';
636 }
637}
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(is_null($wgLocalTZoffset)) if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:657
if(! $wgRequest->checkUrlExtension()) if(isset($_SERVER[ 'PATH_INFO']) &&$_SERVER[ 'PATH_INFO'] !='') if(! $wgEnableAPI) $wgTitle
Definition api.php:68
This abstract class implements many basic API functions, and is the base of all API classes.
Definition ApiBase.php:39
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition ApiBase.php:106
getMain()
Get the main module.
Definition ApiBase.php:480
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition ApiBase.php:88
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition ApiBase.php:50
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
Definition ApiBase.php:132
dieReadOnly()
Helper function for readonly errors.
Definition ApiBase.php:2133
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:685
dieUsageMsg( $error)
Output the error message related to a certain array.
Definition ApiBase.php:2144
getResult()
Get the result object.
Definition ApiBase.php:584
getWatchlistValue( $watchlist, $titleObj, $userOption=null)
Return true if we're to watch the page, false if not, null if no change.
Definition ApiBase.php:877
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:464
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition ApiBase.php:840
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition ApiBase.php:2984
dieStatus( $status)
Throw a UsageException based on the errors in the Status object.
Definition ApiBase.php:1615
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
Definition ApiBase.php:1526
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition ApiBase.php:53
A module that allows for editing and creating pages.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
needsToken()
Returns the token type this module requires in order to execute.
isWriteMode()
Indicates whether this module requires write mode.
mustBePosted()
Indicates whether this module must be called with a POST request.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
static getBlockInfo(Block $block)
Get basic info about a given block.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition Article.php:146
static canAddTagsAccompanyingChange(array $tags, User $user=null)
Is it OK to allow the user to apply all the specified tags at the same time as they edit/make the cha...
static getAllContentFormats()
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getContentModels()
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
getTitle()
Get the Title object.
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
The edit page/HTML interface (split from Article) The actual database and text munging is still in Ar...
Definition EditPage.php:38
const AS_HOOK_ERROR_EXPECTED
Status: A hook function returned an error.
Definition EditPage.php:57
const AS_READ_ONLY_PAGE_ANON
Status: this anonymous user is not allowed to edit this page.
Definition EditPage.php:72
const AS_MAX_ARTICLE_SIZE_EXCEEDED
Status: article is too big (> $wgMaxArticleSize), after merging in the new section.
Definition EditPage.php:125
const AS_CONFLICT_DETECTED
Status: (non-resolvable) edit conflict.
Definition EditPage.php:109
const AS_SPAM_ERROR
Status: summary contained spam according to one of the regexes in $wgSummarySpamRegex.
Definition EditPage.php:135
const AS_READ_ONLY_PAGE_LOGGED
Status: this logged in user is not allowed to edit this page.
Definition EditPage.php:77
const AS_BLANK_ARTICLE
Status: user tried to create a blank page and wpIgnoreBlankArticle == false.
Definition EditPage.php:104
const AS_PARSE_ERROR
Status: can't parse content.
Definition EditPage.php:168
const AS_READ_ONLY_PAGE
Status: wiki is in readonly mode (wfReadOnly() == true)
Definition EditPage.php:82
const AS_CONTENT_TOO_BIG
Status: Content too big (> $wgMaxArticleSize)
Definition EditPage.php:67
const AS_CHANGE_TAG_ERROR
Status: an error relating to change tagging.
Definition EditPage.php:163
const AS_BLOCKED_PAGE_FOR_USER
Status: User is blocked from editing this page.
Definition EditPage.php:62
const AS_NO_CHANGE_CONTENT_MODEL
Status: user tried to modify the content model, but is not allowed to do that ( User::isAllowed('edit...
Definition EditPage.php:151
const AS_IMAGE_REDIRECT_LOGGED
Status: logged in user is not allowed to upload (User::isAllowed('upload') == false)
Definition EditPage.php:145
const AS_END
Status: WikiPage::doEdit() was unsuccessful.
Definition EditPage.php:130
const AS_ARTICLE_WAS_DELETED
Status: article was deleted while editing and param wpRecreate == false or form was not posted.
Definition EditPage.php:93
const AS_TEXTBOX_EMPTY
Status: user tried to create a new section without content.
Definition EditPage.php:120
const AS_SUCCESS_UPDATE
Status: Article successfully updated.
Definition EditPage.php:42
const AS_IMAGE_REDIRECT_ANON
Status: anonymous user is not allowed to upload (User::isAllowed('upload') == false)
Definition EditPage.php:140
const AS_NO_CREATE_PERMISSION
Status: user tried to create this page, but is not allowed to do that ( Title->userCan('create') == f...
Definition EditPage.php:99
const AS_SUCCESS_NEW_ARTICLE
Status: Article successfully created.
Definition EditPage.php:47
const AS_RATE_LIMITED
Status: rate limiter for action 'edit' was tripped.
Definition EditPage.php:87
const AS_HOOK_ERROR
Status: Article update aborted by a hook function.
Definition EditPage.php:52
const AS_SUMMARY_NEEDED
Status: no edit summary given and the user has forceeditsummary set and the user is not editing in hi...
Definition EditPage.php:115
Exception representing a failure to serialize or unserialize a content object.
Group all the pieces relevant to the context of a request into one instance.
setRequest(WebRequest $r)
Set the WebRequest object.
const DELETED_TEXT
Definition Revision.php:76
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Definition Revision.php:117
const FOR_THIS_USER
Definition Revision.php:84
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition Revision.php:99
Content object implementation for representing flat text.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:99
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
Definition deferred.txt:11
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
versus $oldTitle
Definition globals.txt:16
const NS_MEDIAWIKI
Definition Defines.php:78
this hook is for auditing only $req
Definition hooks.txt:968
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 $status
Definition hooks.txt:1007
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition hooks.txt:1799
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
Definition hooks.txt:1040
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:314
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition hooks.txt:2727
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:37
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition linkcache.txt:17
$params