47 $this->
run( $resultPageSet );
62 if ( !is_null(
$params[
'difftotext'] ) ) {
63 $this->difftotext =
$params[
'difftotext'];
64 $this->difftotextpst =
$params[
'difftotextpst'];
65 } elseif ( !is_null(
$params[
'diffto'] ) ) {
66 if (
$params[
'diffto'] ==
'cur' ) {
69 if ( ( !ctype_digit(
$params[
'diffto'] ) ||
$params[
'diffto'] < 0 )
73 $this->
dieWithError( [
'apierror-baddiffto', $p ],
'diffto' );
84 $this->
addWarning( [
'apiwarn-difftohidden', $difftoRev->getId() ] );
88 $this->diffto =
$params[
'diffto'];
91 $prop = array_flip(
$params[
'prop'] );
93 $this->fld_ids = isset( $prop[
'ids'] );
94 $this->fld_flags = isset( $prop[
'flags'] );
95 $this->fld_timestamp = isset( $prop[
'timestamp'] );
96 $this->fld_comment = isset( $prop[
'comment'] );
97 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
98 $this->fld_size = isset( $prop[
'size'] );
99 $this->fld_sha1 = isset( $prop[
'sha1'] );
100 $this->fld_content = isset( $prop[
'content'] );
101 $this->fld_contentmodel = isset( $prop[
'contentmodel'] );
102 $this->fld_userid = isset( $prop[
'userid'] );
103 $this->fld_user = isset( $prop[
'user'] );
104 $this->fld_tags = isset( $prop[
'tags'] );
105 $this->fld_parsetree = isset( $prop[
'parsetree'] );
107 if ( $this->fld_parsetree ) {
111 $parentParam = $parent->encodeParamName( $parent->getModuleManager()->getModuleGroup( $name ) );
113 [
'apiwarn-deprecation-parameter',
"{$encParam}=parsetree" ],
114 "action=query&{$parentParam}={$name}&{$encParam}=parsetree"
118 if ( !empty(
$params[
'contentformat'] ) ) {
119 $this->contentFormat =
$params[
'contentformat'];
122 $this->limit =
$params[
'limit'];
124 $this->fetchContent = $this->fld_content || !is_null( $this->diffto )
128 if ( $this->fetchContent ) {
130 $this->expandTemplates =
$params[
'expandtemplates'];
131 $this->generateXML =
$params[
'generatexml'];
132 $this->parseContent =
$params[
'parse'];
133 if ( $this->parseContent ) {
135 if ( is_null( $this->limit ) ) {
139 if ( isset(
$params[
'section'] ) ) {
140 $this->section =
$params[
'section'];
142 $this->section =
false;
148 if ( $this->limit ==
'max' ) {
149 $this->limit = $this->
getMain()->canApiHighLimits() ? $botMax : $userMax;
150 if ( $this->setParsedLimit ) {
155 if ( is_null( $this->limit ) ) {
158 $this->
validateLimit(
'limit', $this->limit, 1, $userMax, $botMax );
174 if ( $this->fld_ids ) {
175 $vals[
'revid'] = intval( $revision->
getId() );
177 $vals[
'parentid'] = intval( $revision->
getParentId() );
181 if ( $this->fld_flags ) {
182 $vals[
'minor'] = $revision->
isMinor();
185 if ( $this->fld_user || $this->fld_userid ) {
187 $vals[
'userhidden'] =
true;
191 if ( $this->fld_user ) {
196 $vals[
'anon'] =
true;
199 if ( $this->fld_userid ) {
200 $vals[
'userid'] = $userid;
205 if ( $this->fld_timestamp ) {
209 if ( $this->fld_size ) {
210 if ( !is_null( $revision->
getSize() ) ) {
211 $vals[
'size'] = intval( $revision->
getSize() );
217 if ( $this->fld_sha1 ) {
219 $vals[
'sha1hidden'] =
true;
223 if ( $revision->
getSha1() !=
'' ) {
224 $vals[
'sha1'] = Wikimedia\base_convert( $revision->
getSha1(), 36, 16, 40 );
231 if ( $this->fld_contentmodel ) {
235 if ( $this->fld_comment || $this->fld_parsedcomment ) {
237 $vals[
'commenthidden'] =
true;
243 if ( $this->fld_comment ) {
244 $vals[
'comment'] = $comment;
247 if ( $this->fld_parsedcomment ) {
253 if ( $this->fld_tags ) {
254 if ( $row->ts_tags ) {
255 $tags = explode(
',', $row->ts_tags );
257 $vals[
'tags'] = $tags;
265 if ( $this->fetchContent ) {
270 if ( $content && $this->section !==
false ) {
271 $content = $content->getSection( $this->section,
false );
275 'apierror-nosuchsection-what',
277 $this->
msg(
'revid', $revision->
getId() )
284 $vals[
'texthidden'] =
true;
286 } elseif ( !$content ) {
287 $vals[
'textmissing'] =
true;
290 if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
293 $t = $content->getNativeData(); # note: don
't set $text
295 $wgParser->startExternalParse(
297 ParserOptions::newFromContext( $this->getContext() ),
298 Parser::OT_PREPROCESS
300 $dom = $wgParser->preprocessToDom( $t );
301 if ( is_callable( [ $dom, 'saveXML
' ] ) ) {
302 $xml = $dom->saveXML();
304 $xml = $dom->__toString();
306 $vals['parsetree
'] = $xml;
308 $vals['badcontentformatforparsetree
'] = true;
311 'apierror-parsetree-notwikitext-title
',
312 wfEscapeWikiText( $title->getPrefixedText() ),
315 'parsetree-notwikitext
'
321 if ( $this->fld_content && $content ) {
324 if ( $this->expandTemplates && !$this->parseContent ) {
325 # XXX: implement template expansion for all content types in ContentHandler?
326 if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
327 $text = $content->getNativeData();
329 $text = $wgParser->preprocess(
332 ParserOptions::newFromContext( $this->getContext() )
336 'apierror-templateexpansion-notwikitext
',
337 wfEscapeWikiText( $title->getPrefixedText() ),
340 $vals['badcontentformat
'] = true;
344 if ( $this->parseContent ) {
345 $po = $content->getParserOutput(
348 ParserOptions::newFromContext( $this->getContext() )
350 $text = $po->getText();
353 if ( $text === null ) {
354 $format = $this->contentFormat ?: $content->getDefaultFormat();
355 $model = $content->getModel();
357 if ( !$content->isSupportedFormat( $format ) ) {
358 $name = wfEscapeWikiText( $title->getPrefixedText() );
359 $this->addWarning( [ 'apierror-badformat
', $this->contentFormat, $model, $name ] );
360 $vals['badcontentformat
'] = true;
363 $text = $content->serialize( $format );
364 // always include format and model.
365 // Format is needed to deserialize, model is needed to interpret.
366 $vals['contentformat
'] = $format;
367 $vals['contentmodel
'] = $model;
371 if ( $text !== false ) {
372 ApiResult::setContentValue( $vals, 'content
', $text );
376 if ( $content && ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) ) {
377 static $n = 0; // Number of uncached diffs we've had
379 if ( $n < $this->
getConfig()->
get(
'APIMaxUncachedDiffs' ) ) {
385 if ( !is_null( $this->difftotext ) ) {
386 $model = $title->getContentModel();
388 if ( $this->contentFormat
392 $this->
addWarning( [
'apierror-badformat', $this->contentFormat, $model, $name ] );
393 $vals[
'diff'][
'badcontentformat'] =
true;
403 if ( $this->difftotextpst ) {
404 $popts = ParserOptions::newFromContext( $this->
getContext() );
405 $difftocontent = $difftocontent->preSaveTransform( $title, $user, $popts );
409 $engine->setContent( $content, $difftocontent );
413 $vals[
'diff'][
'from'] =
$engine->getOldid();
414 $vals[
'diff'][
'to'] =
$engine->getNewid();
417 $difftext =
$engine->getDiffBody();
419 if ( !
$engine->wasCacheHit() ) {
424 $vals[
'diff'][
'notcached'] =
true;
429 $vals[
'suppressed'] =
true;
465 'ids' =>
'apihelp-query+revisions+base-paramvalue-prop-ids',
466 'flags' =>
'apihelp-query+revisions+base-paramvalue-prop-flags',
467 'timestamp' =>
'apihelp-query+revisions+base-paramvalue-prop-timestamp',
468 'user' =>
'apihelp-query+revisions+base-paramvalue-prop-user',
469 'userid' =>
'apihelp-query+revisions+base-paramvalue-prop-userid',
470 'size' =>
'apihelp-query+revisions+base-paramvalue-prop-size',
471 'sha1' =>
'apihelp-query+revisions+base-paramvalue-prop-sha1',
472 'contentmodel' =>
'apihelp-query+revisions+base-paramvalue-prop-contentmodel',
473 'comment' =>
'apihelp-query+revisions+base-paramvalue-prop-comment',
474 'parsedcomment' =>
'apihelp-query+revisions+base-paramvalue-prop-parsedcomment',
475 'content' =>
'apihelp-query+revisions+base-paramvalue-prop-content',
476 'tags' =>
'apihelp-query+revisions+base-paramvalue-prop-tags',
477 'parsetree' => [
'apihelp-query+revisions+base-paramvalue-prop-parsetree',
488 'expandtemplates' => [
490 ApiBase::PARAM_HELP_MSG =>
'apihelp-query+revisions+base-param-expandtemplates',
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when run
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.
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 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.
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
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.
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...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
extractRevisionInfo(Revision $revision, $row)
Extract information from the Revision.
run(ApiPageSet $resultPageSet=null)
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
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.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getUser()
Get the User object.
getConfig()
Get the Config object.
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...
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
getTitle()
Returns the title of the page associated with this entry or null.
getSize()
Returns the length of the text in this revision, or null if unknown.
getContentHandler()
Returns the content handler appropriate for this revision's content model.
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment if it's available to the specified audience.
getContentModel()
Returns the content model for this revision.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
getParentId()
Get parent revision ID (the original previous page revision)
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
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
the value to return A Title object or null for latest all implement SearchIndexField $engine
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
const CONTENT_MODEL_WIKITEXT