MediaWiki  1.28.0
ApiQueryRevisionsBase.php
Go to the documentation of this file.
1 <?php
33 
35  $section, $parseContent, $fetchContent, $contentFormat, $setParsedLimit = true;
36 
37  protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
38  $fld_size = false, $fld_sha1 = false, $fld_comment = false,
39  $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
40  $fld_content = false, $fld_tags = false, $fld_contentmodel = false, $fld_parsetree = false;
41 
42  public function execute() {
43  $this->run();
44  }
45 
46  public function executeGenerator( $resultPageSet ) {
47  $this->run( $resultPageSet );
48  }
49 
54  abstract protected function run( ApiPageSet $resultPageSet = null );
55 
61  protected function parseParameters( $params ) {
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' ) {
67  $params['diffto'] = 0;
68  }
69  if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 )
70  && $params['diffto'] != 'prev' && $params['diffto'] != 'next'
71  ) {
72  $p = $this->getModulePrefix();
73  $this->dieUsage(
74  "{$p}diffto must be set to a non-negative number, \"prev\", \"next\" or \"cur\"",
75  'diffto'
76  );
77  }
78  // Check whether the revision exists and is readable,
79  // DifferenceEngine returns a rather ambiguous empty
80  // string if that's not the case
81  if ( $params['diffto'] != 0 ) {
82  $difftoRev = Revision::newFromId( $params['diffto'] );
83  if ( !$difftoRev ) {
84  $this->dieUsageMsg( [ 'nosuchrevid', $params['diffto'] ] );
85  }
86  if ( !$difftoRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
87  $this->setWarning( "Couldn't diff to r{$difftoRev->getId()}: content is hidden" );
88  $params['diffto'] = null;
89  }
90  }
91  $this->diffto = $params['diffto'];
92  }
93 
94  $prop = array_flip( $params['prop'] );
95 
96  $this->fld_ids = isset( $prop['ids'] );
97  $this->fld_flags = isset( $prop['flags'] );
98  $this->fld_timestamp = isset( $prop['timestamp'] );
99  $this->fld_comment = isset( $prop['comment'] );
100  $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
101  $this->fld_size = isset( $prop['size'] );
102  $this->fld_sha1 = isset( $prop['sha1'] );
103  $this->fld_content = isset( $prop['content'] );
104  $this->fld_contentmodel = isset( $prop['contentmodel'] );
105  $this->fld_userid = isset( $prop['userid'] );
106  $this->fld_user = isset( $prop['user'] );
107  $this->fld_tags = isset( $prop['tags'] );
108  $this->fld_parsetree = isset( $prop['parsetree'] );
109 
110  if ( !empty( $params['contentformat'] ) ) {
111  $this->contentFormat = $params['contentformat'];
112  }
113 
114  $this->limit = $params['limit'];
115 
116  $this->fetchContent = $this->fld_content || !is_null( $this->diffto )
117  || !is_null( $this->difftotext ) || $this->fld_parsetree;
118 
119  $smallLimit = false;
120  if ( $this->fetchContent ) {
121  $smallLimit = true;
122  $this->expandTemplates = $params['expandtemplates'];
123  $this->generateXML = $params['generatexml'];
124  $this->parseContent = $params['parse'];
125  if ( $this->parseContent ) {
126  // Must manually initialize unset limit
127  if ( is_null( $this->limit ) ) {
128  $this->limit = 1;
129  }
130  }
131  if ( isset( $params['section'] ) ) {
132  $this->section = $params['section'];
133  } else {
134  $this->section = false;
135  }
136  }
137 
138  $userMax = $this->parseContent ? 1 : ( $smallLimit ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 );
139  $botMax = $this->parseContent ? 1 : ( $smallLimit ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 );
140  if ( $this->limit == 'max' ) {
141  $this->limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
142  if ( $this->setParsedLimit ) {
143  $this->getResult()->addParsedLimit( $this->getModuleName(), $this->limit );
144  }
145  }
146 
147  if ( is_null( $this->limit ) ) {
148  $this->limit = 10;
149  }
150  $this->validateLimit( 'limit', $this->limit, 1, $userMax, $botMax );
151  }
152 
160  protected function extractRevisionInfo( Revision $revision, $row ) {
161  $title = $revision->getTitle();
162  $user = $this->getUser();
163  $vals = [];
164  $anyHidden = false;
165 
166  if ( $this->fld_ids ) {
167  $vals['revid'] = intval( $revision->getId() );
168  if ( !is_null( $revision->getParentId() ) ) {
169  $vals['parentid'] = intval( $revision->getParentId() );
170  }
171  }
172 
173  if ( $this->fld_flags ) {
174  $vals['minor'] = $revision->isMinor();
175  }
176 
177  if ( $this->fld_user || $this->fld_userid ) {
178  if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
179  $vals['userhidden'] = true;
180  $anyHidden = true;
181  }
182  if ( $revision->userCan( Revision::DELETED_USER, $user ) ) {
183  if ( $this->fld_user ) {
184  $vals['user'] = $revision->getUserText( Revision::RAW );
185  }
186  $userid = $revision->getUser( Revision::RAW );
187  if ( !$userid ) {
188  $vals['anon'] = true;
189  }
190 
191  if ( $this->fld_userid ) {
192  $vals['userid'] = $userid;
193  }
194  }
195  }
196 
197  if ( $this->fld_timestamp ) {
198  $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $revision->getTimestamp() );
199  }
200 
201  if ( $this->fld_size ) {
202  if ( !is_null( $revision->getSize() ) ) {
203  $vals['size'] = intval( $revision->getSize() );
204  } else {
205  $vals['size'] = 0;
206  }
207  }
208 
209  if ( $this->fld_sha1 ) {
210  if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
211  $vals['sha1hidden'] = true;
212  $anyHidden = true;
213  }
214  if ( $revision->userCan( Revision::DELETED_TEXT, $user ) ) {
215  if ( $revision->getSha1() != '' ) {
216  $vals['sha1'] = Wikimedia\base_convert( $revision->getSha1(), 36, 16, 40 );
217  } else {
218  $vals['sha1'] = '';
219  }
220  }
221  }
222 
223  if ( $this->fld_contentmodel ) {
224  $vals['contentmodel'] = $revision->getContentModel();
225  }
226 
227  if ( $this->fld_comment || $this->fld_parsedcomment ) {
228  if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) {
229  $vals['commenthidden'] = true;
230  $anyHidden = true;
231  }
232  if ( $revision->userCan( Revision::DELETED_COMMENT, $user ) ) {
233  $comment = $revision->getComment( Revision::RAW );
234 
235  if ( $this->fld_comment ) {
236  $vals['comment'] = $comment;
237  }
238 
239  if ( $this->fld_parsedcomment ) {
240  $vals['parsedcomment'] = Linker::formatComment( $comment, $title );
241  }
242  }
243  }
244 
245  if ( $this->fld_tags ) {
246  if ( $row->ts_tags ) {
247  $tags = explode( ',', $row->ts_tags );
248  ApiResult::setIndexedTagName( $tags, 'tag' );
249  $vals['tags'] = $tags;
250  } else {
251  $vals['tags'] = [];
252  }
253  }
254 
255  $content = null;
257  if ( $this->fetchContent ) {
258  $content = $revision->getContent( Revision::FOR_THIS_USER, $this->getUser() );
259  // Expand templates after getting section content because
260  // template-added sections don't count and Parser::preprocess()
261  // will have less input
262  if ( $content && $this->section !== false ) {
263  $content = $content->getSection( $this->section, false );
264  if ( !$content ) {
265  $this->dieUsage(
266  "There is no section {$this->section} in r" . $revision->getId(),
267  'nosuchsection'
268  );
269  }
270  }
271  if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
272  $vals['texthidden'] = true;
273  $anyHidden = true;
274  } elseif ( !$content ) {
275  $vals['textmissing'] = true;
276  }
277  }
278  if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
279  if ( $content ) {
280  if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
281  $t = $content->getNativeData(); # note: don't set $text
282 
283  $wgParser->startExternalParse(
284  $title,
285  ParserOptions::newFromContext( $this->getContext() ),
286  Parser::OT_PREPROCESS
287  );
288  $dom = $wgParser->preprocessToDom( $t );
289  if ( is_callable( [ $dom, 'saveXML' ] ) ) {
290  $xml = $dom->saveXML();
291  } else {
292  $xml = $dom->__toString();
293  }
294  $vals['parsetree'] = $xml;
295  } else {
296  $vals['badcontentformatforparsetree'] = true;
297  $this->setWarning( 'Conversion to XML is supported for wikitext only, ' .
298  $title->getPrefixedDBkey() .
299  ' uses content model ' . $content->getModel() );
300  }
301  }
302  }
303 
304  if ( $this->fld_content && $content ) {
305  $text = null;
306 
307  if ( $this->expandTemplates && !$this->parseContent ) {
308  # XXX: implement template expansion for all content types in ContentHandler?
309  if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
310  $text = $content->getNativeData();
311 
312  $text = $wgParser->preprocess(
313  $text,
314  $title,
315  ParserOptions::newFromContext( $this->getContext() )
316  );
317  } else {
318  $this->setWarning( 'Template expansion is supported for wikitext only, ' .
319  $title->getPrefixedDBkey() .
320  ' uses content model ' . $content->getModel() );
321  $vals['badcontentformat'] = true;
322  $text = false;
323  }
324  }
325  if ( $this->parseContent ) {
326  $po = $content->getParserOutput(
327  $title,
328  $revision->getId(),
329  ParserOptions::newFromContext( $this->getContext() )
330  );
331  $text = $po->getText();
332  }
333 
334  if ( $text === null ) {
335  $format = $this->contentFormat ?: $content->getDefaultFormat();
336  $model = $content->getModel();
337 
338  if ( !$content->isSupportedFormat( $format ) ) {
339  $name = $title->getPrefixedDBkey();
340  $this->setWarning( "The requested format {$this->contentFormat} is not " .
341  "supported for content model $model used by $name" );
342  $vals['badcontentformat'] = true;
343  $text = false;
344  } else {
345  $text = $content->serialize( $format );
346  // always include format and model.
347  // Format is needed to deserialize, model is needed to interpret.
348  $vals['contentformat'] = $format;
349  $vals['contentmodel'] = $model;
350  }
351  }
352 
353  if ( $text !== false ) {
354  ApiResult::setContentValue( $vals, 'content', $text );
355  }
356  }
357 
358  if ( $content && ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) ) {
359  static $n = 0; // Number of uncached diffs we've had
360 
361  if ( $n < $this->getConfig()->get( 'APIMaxUncachedDiffs' ) ) {
362  $vals['diff'] = [];
363  $context = new DerivativeContext( $this->getContext() );
364  $context->setTitle( $title );
365  $handler = $revision->getContentHandler();
366 
367  if ( !is_null( $this->difftotext ) ) {
368  $model = $title->getContentModel();
369 
370  if ( $this->contentFormat
371  && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat )
372  ) {
373  $name = $title->getPrefixedDBkey();
374  $this->setWarning( "The requested format {$this->contentFormat} is not " .
375  "supported for content model $model used by $name" );
376  $vals['diff']['badcontentformat'] = true;
377  $engine = null;
378  } else {
379  $difftocontent = ContentHandler::makeContent(
380  $this->difftotext,
381  $title,
382  $model,
383  $this->contentFormat
384  );
385 
386  if ( $this->difftotextpst ) {
387  $popts = ParserOptions::newFromContext( $this->getContext() );
388  $difftocontent = $difftocontent->preSaveTransform( $title, $user, $popts );
389  }
390 
391  $engine = $handler->createDifferenceEngine( $context );
392  $engine->setContent( $content, $difftocontent );
393  }
394  } else {
395  $engine = $handler->createDifferenceEngine( $context, $revision->getId(), $this->diffto );
396  $vals['diff']['from'] = $engine->getOldid();
397  $vals['diff']['to'] = $engine->getNewid();
398  }
399  if ( $engine ) {
400  $difftext = $engine->getDiffBody();
401  ApiResult::setContentValue( $vals['diff'], 'body', $difftext );
402  if ( !$engine->wasCacheHit() ) {
403  $n++;
404  }
405  }
406  } else {
407  $vals['diff']['notcached'] = true;
408  }
409  }
410 
411  if ( $anyHidden && $revision->isDeleted( Revision::DELETED_RESTRICTED ) ) {
412  $vals['suppressed'] = true;
413  }
414 
415  return $vals;
416  }
417 
418  public function getCacheMode( $params ) {
419  if ( $this->userCanSeeRevDel() ) {
420  return 'private';
421  }
422 
423  return 'public';
424  }
425 
426  public function getAllowedParams() {
427  return [
428  'prop' => [
429  ApiBase::PARAM_ISMULTI => true,
430  ApiBase::PARAM_DFLT => 'ids|timestamp|flags|comment|user',
432  'ids',
433  'flags',
434  'timestamp',
435  'user',
436  'userid',
437  'size',
438  'sha1',
439  'contentmodel',
440  'comment',
441  'parsedcomment',
442  'content',
443  'tags',
444  'parsetree',
445  ],
446  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-prop',
448  'ids' => 'apihelp-query+revisions+base-paramvalue-prop-ids',
449  'flags' => 'apihelp-query+revisions+base-paramvalue-prop-flags',
450  'timestamp' => 'apihelp-query+revisions+base-paramvalue-prop-timestamp',
451  'user' => 'apihelp-query+revisions+base-paramvalue-prop-user',
452  'userid' => 'apihelp-query+revisions+base-paramvalue-prop-userid',
453  'size' => 'apihelp-query+revisions+base-paramvalue-prop-size',
454  'sha1' => 'apihelp-query+revisions+base-paramvalue-prop-sha1',
455  'contentmodel' => 'apihelp-query+revisions+base-paramvalue-prop-contentmodel',
456  'comment' => 'apihelp-query+revisions+base-paramvalue-prop-comment',
457  'parsedcomment' => 'apihelp-query+revisions+base-paramvalue-prop-parsedcomment',
458  'content' => 'apihelp-query+revisions+base-paramvalue-prop-content',
459  'tags' => 'apihelp-query+revisions+base-paramvalue-prop-tags',
460  'parsetree' => [ 'apihelp-query+revisions+base-paramvalue-prop-parsetree',
462  ],
463  ],
464  'limit' => [
465  ApiBase::PARAM_TYPE => 'limit',
466  ApiBase::PARAM_MIN => 1,
469  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-limit',
470  ],
471  'expandtemplates' => [
472  ApiBase::PARAM_DFLT => false,
473  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-expandtemplates',
474  ],
475  'generatexml' => [
476  ApiBase::PARAM_DFLT => false,
478  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-generatexml',
479  ],
480  'parse' => [
481  ApiBase::PARAM_DFLT => false,
482  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-parse',
483  ],
484  'section' => [
485  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-section',
486  ],
487  'diffto' => [
488  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-diffto',
489  ],
490  'difftotext' => [
491  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-difftotext',
492  ],
493  'difftotextpst' => [
494  ApiBase::PARAM_DFLT => false,
495  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-difftotextpst',
496  ],
497  'contentformat' => [
499  ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-contentformat',
500  ],
501  ];
502  }
503 
504 }
const FOR_THIS_USER
Definition: Revision.php:93
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
Definition: ApiBase.php:88
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition: ApiBase.php:179
getResult()
Get the result object.
Definition: ApiBase.php:577
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:239
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:41
static getAllContentFormats()
per default it will return the text for text based content
getTimestamp()
Definition: Revision.php:1194
static getForModelID($modelId)
Returns the ContentHandler singleton for the given model ID.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server.Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use.Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves.The master writes thequery to the binlog when the transaction is committed.The slaves pollthe binlog and start executing the query as soon as it appears.They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes.Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load.MediaWiki's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database.All edits and other write operations will berefused, with an error returned to the user.This gives the slaves achance to catch up.Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order.A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests.This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it.Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in"lagged slave mode".Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode().The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time.Multi-row INSERT...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it's not practical to guarantee a low-lagenvironment.Lag will usually be less than one second, but mayoccasionally be up to 30 seconds.For scalability, it's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer.So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum.In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks.By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent.Locks willbe held from the time when the query is done until the commit.So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction.Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:50
getMain()
Get the main module.
Definition: ApiBase.php:473
$wgParser
Definition: Setup.php:821
const LIMIT_BIG1
Fast query, standard limit.
Definition: ApiBase.php:177
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:91
An IContextSource implementation which will inherit context from another source but allow individual ...
$comment
A base class for functions common to producing a list of revisions.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
Definition: ApiBase.php:157
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
Definition: ApiResult.php:480
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
Definition: defines.php:28
extractRevisionInfo(Revision $revision, $row)
Extract information from the Revision.
IContextSource $context
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:618
parseParameters($params)
Parse the parameters into the various instance fields.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
isDeleted($field)
Definition: Revision.php:1015
getTitle()
Returns the title of the page associated with this entry or null.
Definition: Revision.php:803
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:774
!article Main Page!text blah blah!endarticle!article Foo!text FOO!endarticle!article Template
getUserText($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
Definition: Revision.php:897
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
getId()
Get revision ID.
Definition: Revision.php:729
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition: Revision.php:1175
getConfig()
Get the Config object.
const LIMIT_SML2
Slow query, apihighlimits limit.
Definition: ApiBase.php:183
getContext()
Get the base IContextSource object.
$params
userCan($field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.
Definition: Revision.php:1746
getComment($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment if it's available to the specified audience.
Definition: Revision.php:941
const DELETED_RESTRICTED
Definition: Revision.php:88
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:953
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:457
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right, for PARAM_TYPE 'limit'.
Definition: ApiBase.php:97
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
setWarning($warning)
Set warning section for this module.
Definition: ApiBase.php:1543
const RAW
Definition: Revision.php:94
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...
Definition: Linker.php:1180
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter...
Definition: ApiBase.php:125
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:242
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2736
getContentModel()
Returns the content model for this revision.
Definition: Revision.php:1134
const DELETED_TEXT
Definition: Revision.php:85
const LIMIT_SML1
Slow query, standard limit.
Definition: ApiBase.php:181
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:110
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:35
executeGenerator($resultPageSet)
const DELETED_USER
Definition: Revision.php:87
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
Definition: ApiBase.php:465
validateLimit($paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
Validate the value against the minimum and user/bot maximum limits.
Definition: ApiBase.php:1285
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:1046
getContent($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:1073
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:53
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:1574
run(ApiPageSet $resultPageSet=null)
getUser($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
Definition: Revision.php:863
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:106
const DELETED_COMMENT
Definition: Revision.php:86
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
Definition: hooks.txt:802
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:100
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:783
getUser()
Get the User object.
dieUsageMsg($error)
Output the error message related to a certain array.
Definition: ApiBase.php:2192
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
Definition: Revision.php:792
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:300