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 ( !empty(
$params[
'contentformat'] ) ) {
108 $this->contentFormat =
$params[
'contentformat'];
111 $this->limit =
$params[
'limit'];
113 $this->fetchContent = $this->fld_content || !is_null( $this->diffto )
117 if ( $this->fetchContent ) {
119 $this->expandTemplates =
$params[
'expandtemplates'];
120 $this->generateXML =
$params[
'generatexml'];
121 $this->parseContent =
$params[
'parse'];
122 if ( $this->parseContent ) {
124 if ( is_null( $this->limit ) ) {
128 if ( isset(
$params[
'section'] ) ) {
129 $this->section =
$params[
'section'];
131 $this->section =
false;
137 if ( $this->limit ==
'max' ) {
138 $this->limit = $this->
getMain()->canApiHighLimits() ? $botMax : $userMax;
139 if ( $this->setParsedLimit ) {
144 if ( is_null( $this->limit ) ) {
147 $this->
validateLimit(
'limit', $this->limit, 1, $userMax, $botMax );
163 if ( $this->fld_ids ) {
164 $vals[
'revid'] = intval( $revision->
getId() );
166 $vals[
'parentid'] = intval( $revision->
getParentId() );
170 if ( $this->fld_flags ) {
171 $vals[
'minor'] = $revision->
isMinor();
174 if ( $this->fld_user || $this->fld_userid ) {
176 $vals[
'userhidden'] =
true;
180 if ( $this->fld_user ) {
185 $vals[
'anon'] =
true;
188 if ( $this->fld_userid ) {
189 $vals[
'userid'] = $userid;
194 if ( $this->fld_timestamp ) {
198 if ( $this->fld_size ) {
199 if ( !is_null( $revision->
getSize() ) ) {
200 $vals[
'size'] = intval( $revision->
getSize() );
206 if ( $this->fld_sha1 ) {
208 $vals[
'sha1hidden'] =
true;
212 if ( $revision->
getSha1() !=
'' ) {
213 $vals[
'sha1'] = Wikimedia\base_convert( $revision->
getSha1(), 36, 16, 40 );
220 if ( $this->fld_contentmodel ) {
224 if ( $this->fld_comment || $this->fld_parsedcomment ) {
226 $vals[
'commenthidden'] =
true;
232 if ( $this->fld_comment ) {
233 $vals[
'comment'] = $comment;
236 if ( $this->fld_parsedcomment ) {
242 if ( $this->fld_tags ) {
243 if ( $row->ts_tags ) {
244 $tags = explode(
',', $row->ts_tags );
246 $vals[
'tags'] = $tags;
254 if ( $this->fetchContent ) {
259 if (
$content && $this->section !==
false ) {
264 'apierror-nosuchsection-what',
266 $this->
msg(
'revid', $revision->
getId() )
273 $vals[
'texthidden'] =
true;
276 $vals[
'textmissing'] =
true;
279 if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
282 $t =
$content->getNativeData(); # note: don
't set $text
284 $wgParser->startExternalParse(
286 ParserOptions::newFromContext( $this->getContext() ),
287 Parser::OT_PREPROCESS
289 $dom = $wgParser->preprocessToDom( $t );
290 if ( is_callable( [ $dom, 'saveXML
' ] ) ) {
291 $xml = $dom->saveXML();
293 $xml = $dom->__toString();
295 $vals['parsetree
'] = $xml;
297 $vals['badcontentformatforparsetree
'] = true;
300 'apierror-parsetree-notwikitext-
title',
301 wfEscapeWikiText( $title->getPrefixedText() ),
304 'parsetree-notwikitext
'
310 if ( $this->fld_content && $content ) {
313 if ( $this->expandTemplates && !$this->parseContent ) {
314 # XXX: implement template expansion for all content types in ContentHandler?
315 if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
316 $text = $content->getNativeData();
318 $text = $wgParser->preprocess(
321 ParserOptions::newFromContext( $this->getContext() )
325 'apierror-templateexpansion-notwikitext
',
326 wfEscapeWikiText( $title->getPrefixedText() ),
329 $vals['badcontentformat
'] = true;
333 if ( $this->parseContent ) {
334 $po = $content->getParserOutput(
337 ParserOptions::newFromContext( $this->getContext() )
339 $text = $po->getText();
342 if ( $text === null ) {
343 $format = $this->contentFormat ?: $content->getDefaultFormat();
344 $model = $content->getModel();
346 if ( !$content->isSupportedFormat( $format ) ) {
347 $name = wfEscapeWikiText( $title->getPrefixedText() );
348 $this->addWarning( [ 'apierror-badformat
', $this->contentFormat, $model, $name ] );
349 $vals['badcontentformat
'] = true;
352 $text = $content->serialize( $format );
353 // always include format and model.
354 // Format is needed to deserialize, model is needed to interpret.
355 $vals['contentformat
'] = $format;
356 $vals['contentmodel
'] = $model;
360 if ( $text !== false ) {
361 ApiResult::setContentValue( $vals, 'content', $text );
365 if ( $content && ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) ) {
366 static $n = 0; // Number of uncached diffs we've had
368 if ( $n < $this->
getConfig()->
get(
'APIMaxUncachedDiffs' ) ) {
374 if ( !is_null( $this->difftotext ) ) {
375 $model =
$title->getContentModel();
377 if ( $this->contentFormat
381 $this->
addWarning( [
'apierror-badformat', $this->contentFormat, $model,
$name ] );
382 $vals[
'diff'][
'badcontentformat'] =
true;
392 if ( $this->difftotextpst ) {
394 $difftocontent = $difftocontent->preSaveTransform(
$title,
$user, $popts );
402 $vals[
'diff'][
'from'] =
$engine->getOldid();
403 $vals[
'diff'][
'to'] =
$engine->getNewid();
406 $difftext =
$engine->getDiffBody();
408 if ( !
$engine->wasCacheHit() ) {
413 $vals[
'diff'][
'notcached'] =
true;
418 $vals[
'suppressed'] =
true;
454 'ids' =>
'apihelp-query+revisions+base-paramvalue-prop-ids',
455 'flags' =>
'apihelp-query+revisions+base-paramvalue-prop-flags',
456 'timestamp' =>
'apihelp-query+revisions+base-paramvalue-prop-timestamp',
457 'user' =>
'apihelp-query+revisions+base-paramvalue-prop-user',
458 'userid' =>
'apihelp-query+revisions+base-paramvalue-prop-userid',
459 'size' =>
'apihelp-query+revisions+base-paramvalue-prop-size',
460 'sha1' =>
'apihelp-query+revisions+base-paramvalue-prop-sha1',
461 'contentmodel' =>
'apihelp-query+revisions+base-paramvalue-prop-contentmodel',
462 'comment' =>
'apihelp-query+revisions+base-paramvalue-prop-comment',
463 'parsedcomment' =>
'apihelp-query+revisions+base-paramvalue-prop-parsedcomment',
464 'content' =>
'apihelp-query+revisions+base-paramvalue-prop-content',
465 'tags' =>
'apihelp-query+revisions+base-paramvalue-prop-tags',
466 'parsetree' => [
'apihelp-query+revisions+base-paramvalue-prop-parsetree',
477 'expandtemplates' => [
479 ApiBase::PARAM_HELP_MSG =>
'apihelp-query+revisions+base-param-expandtemplates',
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...
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.
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.
getUser()
Get the User object.
getConfig()
Get the Config object.
msg()
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...
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
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.
per default it will return the text for text based content
when a variable name is used in a it is silently declared as a new local masking the global
const CONTENT_MODEL_WIKITEXT
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
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
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