63 $this->
run( $resultPageSet );
78 $prop = array_flip(
$params[
'prop'] );
80 $this->fld_ids = isset( $prop[
'ids'] );
81 $this->fld_flags = isset( $prop[
'flags'] );
82 $this->fld_timestamp = isset( $prop[
'timestamp'] );
83 $this->fld_comment = isset( $prop[
'comment'] );
84 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
85 $this->fld_size = isset( $prop[
'size'] );
86 $this->fld_slotsize = isset( $prop[
'slotsize'] );
87 $this->fld_sha1 = isset( $prop[
'sha1'] );
88 $this->fld_slotsha1 = isset( $prop[
'slotsha1'] );
89 $this->fld_content = isset( $prop[
'content'] );
90 $this->fld_contentmodel = isset( $prop[
'contentmodel'] );
91 $this->fld_userid = isset( $prop[
'userid'] );
92 $this->fld_user = isset( $prop[
'user'] );
93 $this->fld_tags = isset( $prop[
'tags'] );
94 $this->fld_roles = isset( $prop[
'roles'] );
95 $this->fld_parsetree = isset( $prop[
'parsetree'] );
97 $this->slotRoles =
$params[
'slots'];
99 if ( $this->slotRoles !==
null ) {
100 if ( $this->fld_parsetree ) {
102 'apierror-invalidparammix-cannotusewith',
105 ],
'invalidparammix' );
108 'expandtemplates',
'generatexml',
'parse',
'diffto',
'difftotext',
'difftotextpst',
113 'apierror-invalidparammix-cannotusewith',
116 ],
'invalidparammix' );
121 if ( !empty(
$params[
'contentformat'] ) ) {
122 $this->contentFormat =
$params[
'contentformat'];
125 $this->limit =
$params[
'limit'];
127 if ( !is_null(
$params[
'difftotext'] ) ) {
128 $this->difftotext =
$params[
'difftotext'];
129 $this->difftotextpst =
$params[
'difftotextpst'];
130 } elseif ( !is_null(
$params[
'diffto'] ) ) {
131 if (
$params[
'diffto'] ==
'cur' ) {
134 if ( ( !ctype_digit(
$params[
'diffto'] ) ||
$params[
'diffto'] < 0 )
138 $this->
dieWithError( [
'apierror-baddiffto', $p ],
'diffto' );
143 if (
$params[
'diffto'] != 0 ) {
144 $difftoRev = MediaWikiServices::getInstance()->getRevisionStore()
145 ->getRevisionById(
$params[
'diffto'] );
149 $revDel = $this->
checkRevDel( $difftoRev, RevisionRecord::DELETED_TEXT );
150 if ( $revDel & self::CANNOT_VIEW ) {
151 $this->
addWarning( [
'apiwarn-difftohidden', $difftoRev->getId() ] );
155 $this->diffto =
$params[
'diffto'];
158 $this->fetchContent = $this->fld_content || !is_null( $this->diffto )
162 if ( $this->fetchContent ) {
164 $this->expandTemplates =
$params[
'expandtemplates'];
165 $this->generateXML =
$params[
'generatexml'];
166 $this->parseContent =
$params[
'parse'];
167 if ( $this->parseContent ) {
169 if ( is_null( $this->limit ) ) {
173 $this->section =
$params[
'section'] ??
false;
178 if ( $this->limit ==
'max' ) {
179 $this->limit = $this->
getMain()->canApiHighLimits() ? $botMax : $userMax;
180 if ( $this->setParsedLimit ) {
185 if ( is_null( $this->limit ) ) {
188 $this->
validateLimit(
'limit', $this->limit, 1, $userMax, $botMax );
190 $this->needSlots = $this->fetchContent || $this->fld_contentmodel ||
192 if ( $this->needSlots && $this->slotRoles ===
null ) {
196 $parentParam =
$parent->encodeParamName(
$parent->getModuleManager()->getModuleGroup(
$name ) );
198 [
'apiwarn-deprecation-missingparam', $encParam ],
199 "action=query&{$parentParam}={$name}&!{$encParam}"
214 $canSee = $revision->
audienceCan( $field, RevisionRecord::FOR_THIS_USER, $this->
getUser() );
232 if ( $this->fld_ids ) {
233 $vals[
'revid'] = (int)$revision->
getId();
239 if ( $this->fld_flags ) {
240 $vals[
'minor'] = $revision->
isMinor();
243 if ( $this->fld_user || $this->fld_userid ) {
244 $revDel = $this->
checkRevDel( $revision, RevisionRecord::DELETED_USER );
245 if ( ( $revDel & self::IS_DELETED ) ) {
246 $vals[
'userhidden'] =
true;
249 if ( !( $revDel & self::CANNOT_VIEW ) ) {
250 $u = $revision->
getUser( RevisionRecord::RAW );
251 if ( $this->fld_user ) {
252 $vals[
'user'] = $u->getName();
254 $userid = $u->getId();
256 $vals[
'anon'] =
true;
259 if ( $this->fld_userid ) {
260 $vals[
'userid'] = $userid;
265 if ( $this->fld_timestamp ) {
269 if ( $this->fld_size ) {
271 $vals[
'size'] = (int)$revision->
getSize();
279 if ( $this->fld_sha1 ) {
280 $revDel = $this->
checkRevDel( $revision, RevisionRecord::DELETED_TEXT );
281 if ( ( $revDel & self::IS_DELETED ) ) {
282 $vals[
'sha1hidden'] =
true;
285 if ( !( $revDel & self::CANNOT_VIEW ) ) {
287 $vals[
'sha1'] = Wikimedia\base_convert( $revision->
getSha1(), 36, 16, 40 );
297 if ( $this->fld_roles ) {
301 if ( $this->needSlots ) {
302 $revDel = $this->
checkRevDel( $revision, RevisionRecord::DELETED_TEXT );
303 if ( ( $this->fld_slotsha1 || $this->fetchContent ) && ( $revDel & self::IS_DELETED ) ) {
311 $vals[
'slotsmissing'] =
true;
313 LoggerFactory::getInstance(
'api-warning' )->error(
314 'Failed to access revision slots',
315 [
'revision' => $revision->
getId(),
'exception' => $ex, ]
319 if ( $this->fld_comment || $this->fld_parsedcomment ) {
320 $revDel = $this->
checkRevDel( $revision, RevisionRecord::DELETED_COMMENT );
321 if ( ( $revDel & self::IS_DELETED ) ) {
322 $vals[
'commenthidden'] =
true;
325 if ( !( $revDel & self::CANNOT_VIEW ) ) {
326 $comment = $revision->
getComment( RevisionRecord::RAW );
327 $comment = $comment ? $comment->text :
'';
329 if ( $this->fld_comment ) {
330 $vals[
'comment'] = $comment;
333 if ( $this->fld_parsedcomment ) {
341 if ( $this->fld_tags ) {
342 if ( $row->ts_tags ) {
343 $tags = explode(
',', $row->ts_tags );
345 $vals[
'tags'] = $tags;
351 if ( $anyHidden && $revision->
isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
352 $vals[
'suppressed'] =
true;
370 if ( $this->slotRoles ===
null ) {
372 $slot = $revision->
getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
376 $vals[
'textmissing'] =
true;
383 if ( !empty( $vals[
'nosuchsection'] ) ) {
386 'apierror-nosuchsection-what',
388 $this->
msg(
'revid', $revision->
getId() )
398 $roles = array_intersect( $this->slotRoles, $revision->
getSlotRoles() );
402 foreach ( $roles as $role ) {
404 $slot = $revision->
getSlot( $role, RevisionRecord::RAW );
408 $vals[
'slots'][$role][
'missing'] =
true;
416 $vals[
'slots'][$role][
'contentmodel'] =
$content->getModel();
417 $vals[
'slots'][$role][
'contentformat'] =
$content->getDefaultFormat();
419 $vals[
'slots'][$role],
444 if ( $this->fld_slotsize ) {
445 $vals[
'size'] = (int)$slot->
getSize();
448 if ( $this->fld_slotsha1 ) {
449 if ( ( $revDel & self::IS_DELETED ) ) {
450 $vals[
'sha1hidden'] =
true;
452 if ( !( $revDel & self::CANNOT_VIEW ) ) {
453 if ( $slot->
getSha1() !=
'' ) {
454 $vals[
'sha1'] = Wikimedia\base_convert( $slot->
getSha1(), 36, 16, 40 );
461 if ( $this->fld_contentmodel ) {
462 $vals[
'contentmodel'] = $slot->
getModel();
466 if ( $this->fetchContent ) {
467 if ( ( $revDel & self::IS_DELETED ) ) {
468 $vals[
'texthidden'] =
true;
470 if ( !( $revDel & self::CANNOT_VIEW ) ) {
475 $vals[
'textmissing'] =
true;
480 if (
$content && $this->section !==
false ) {
483 $vals[
'nosuchsection'] =
true;
504 if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
506 $t =
$content->getText(); # note: don
't set $text
508 $wgParser->startExternalParse(
510 ParserOptions::newFromContext( $this->getContext() ),
511 Parser::OT_PREPROCESS
513 $dom = $wgParser->preprocessToDom( $t );
514 if ( is_callable( [ $dom, 'saveXML
' ] ) ) {
515 $xml = $dom->saveXML();
517 $xml = $dom->__toString();
519 $vals['parsetree
'] = $xml;
521 $vals['badcontentformatforparsetree
'] = true;
524 'apierror-parsetree-notwikitext-
title',
525 wfEscapeWikiText( $title->getPrefixedText() ),
528 'parsetree-notwikitext
'
533 if ( $this->fld_content ) {
536 if ( $this->expandTemplates && !$this->parseContent ) {
537 if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
538 $text = $content->getText();
540 $text = $wgParser->preprocess(
543 ParserOptions::newFromContext( $this->getContext() )
547 'apierror-templateexpansion-notwikitext
',
548 wfEscapeWikiText( $title->getPrefixedText() ),
551 $vals['badcontentformat
'] = true;
555 if ( $this->parseContent ) {
556 $po = $content->getParserOutput(
559 ParserOptions::newFromContext( $this->getContext() )
561 $text = $po->getText();
564 if ( $text === null ) {
565 $format = $this->contentFormat ?: $content->getDefaultFormat();
566 $model = $content->getModel();
568 if ( !$content->isSupportedFormat( $format ) ) {
569 $name = wfEscapeWikiText( $title->getPrefixedText() );
570 $this->addWarning( [ 'apierror-badformat
', $this->contentFormat, $model, $name ] );
571 $vals['badcontentformat
'] = true;
574 $text = $content->serialize( $format );
575 // always include format and model.
576 // Format is needed to deserialize, model is needed to interpret.
577 $vals['contentformat
'] = $format;
578 $vals['contentmodel
'] = $model;
582 if ( $text !== false ) {
583 ApiResult::setContentValue( $vals, 'content', $text );
587 if ( $content && ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) ) {
588 static $n = 0; // Number of uncached diffs we've had
590 if ( $n < $this->getConfig()->
get(
'APIMaxUncachedDiffs' ) ) {
596 if ( !is_null( $this->difftotext ) ) {
597 $model =
$title->getContentModel();
599 if ( $this->contentFormat
600 && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat )
603 $this->addWarning( [
'apierror-badformat', $this->contentFormat, $model,
$name ] );
604 $vals[
'diff'][
'badcontentformat'] =
true;
607 $difftocontent = ContentHandler::makeContent(
614 if ( $this->difftotextpst ) {
615 $popts = ParserOptions::newFromContext( $this->
getContext() );
616 $difftocontent = $difftocontent->preSaveTransform(
$title, $this->getUser(), $popts );
624 $vals[
'diff'][
'from'] =
$engine->getOldid();
625 $vals[
'diff'][
'to'] =
$engine->getNewid();
628 $difftext =
$engine->getDiffBody();
630 if ( !
$engine->wasCacheHit() ) {
635 $vals[
'diff'][
'notcached'] =
true;
643 if ( $this->userCanSeeRevDel() ) {
651 $slotRoles = MediaWikiServices::getInstance()->getSlotRoleRegistry()->getKnownRoles();
652 sort( $slotRoles, SORT_STRING );
678 'ids' =>
'apihelp-query+revisions+base-paramvalue-prop-ids',
679 'flags' =>
'apihelp-query+revisions+base-paramvalue-prop-flags',
680 'timestamp' =>
'apihelp-query+revisions+base-paramvalue-prop-timestamp',
681 'user' =>
'apihelp-query+revisions+base-paramvalue-prop-user',
682 'userid' =>
'apihelp-query+revisions+base-paramvalue-prop-userid',
683 'size' =>
'apihelp-query+revisions+base-paramvalue-prop-size',
684 'slotsize' =>
'apihelp-query+revisions+base-paramvalue-prop-slotsize',
685 'sha1' =>
'apihelp-query+revisions+base-paramvalue-prop-sha1',
686 'slotsha1' =>
'apihelp-query+revisions+base-paramvalue-prop-slotsha1',
687 'contentmodel' =>
'apihelp-query+revisions+base-paramvalue-prop-contentmodel',
688 'comment' =>
'apihelp-query+revisions+base-paramvalue-prop-comment',
689 'parsedcomment' =>
'apihelp-query+revisions+base-paramvalue-prop-parsedcomment',
690 'content' =>
'apihelp-query+revisions+base-paramvalue-prop-content',
691 'tags' =>
'apihelp-query+revisions+base-paramvalue-prop-tags',
692 'roles' =>
'apihelp-query+revisions+base-paramvalue-prop-roles',
693 'parsetree' => [
'apihelp-query+revisions+base-paramvalue-prop-parsetree',
713 'expandtemplates' => [
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
getMain()
Get the main module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
addDeprecation( $msg, $feature, $data=[])
Add a deprecation warning for this module.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
const LIMIT_BIG1
Fast query, standard limit.
const LIMIT_SML2
Slow query, apihighlimits limit.
validateLimit( $paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
Validate the value against the minimum and user/bot maximum limits.
getResult()
Get the result object.
const LIMIT_SML1
Slow query, standard limit.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
const PARAM_ALL
(boolean|string) When PARAM_TYPE has a defined set of values and PARAM_ISMULTI is true,...
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
This class contains a list of pages that the client has requested.
encodeParamName( $paramName)
Overrides ApiBase to prepend 'g' to every generator parameter.
A base class for functions common to producing a list of revisions.
executeGenerator( $resultPageSet)
Execute this module as a generator.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
extractAllSlotInfo(RevisionRecord $revision, $revDel)
Extracts information about all relevant slots.
parseParameters( $params)
Parse the parameters into the various instance fields.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
extractDeprecatedContent(Content $content, RevisionRecord $revision)
Format a Content using deprecated options.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
extractSlotInfo(SlotRecord $slot, $revDel, &$content=null)
Extract information from the SlotRecord.
run(ApiPageSet $resultPageSet=null)
checkRevDel(RevisionRecord $revision, $field)
Test revision deletion status.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
const META_KVP_MERGE
Key for the metadata item that indicates that the KVP key should be added into an assoc value,...
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
An IContextSource implementation which will inherit context from another source but allow individual ...
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
per default it will return the text for text based content
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
const CONTENT_MODEL_WIKITEXT
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 it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
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 & $ret
Allows to change the fields on the form that will be generated $name
the value to return A Title object or null for latest all implement SearchIndexField $engine
returning false will NOT prevent logging $e
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
Base interface for content objects.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))