MediaWiki  master
ApiQueryAllDeletedRevisions.php
Go to the documentation of this file.
1 <?php
28 
35 
36  public function __construct( ApiQuery $query, $moduleName ) {
37  parent::__construct( $query, $moduleName, 'adr' );
38  }
39 
44  protected function run( ApiPageSet $resultPageSet = null ) {
45  // Before doing anything at all, let's check permissions
46  $this->checkUserRightsAny( 'deletedhistory' );
47 
48  $user = $this->getUser();
49  $db = $this->getDB();
50  $params = $this->extractRequestParams( false );
51  $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
52 
53  $result = $this->getResult();
54 
55  // If the user wants no namespaces, they get no pages.
56  if ( $params['namespace'] === [] ) {
57  if ( $resultPageSet === null ) {
58  $result->addValue( 'query', $this->getModuleName(), [] );
59  }
60  return;
61  }
62 
63  // This module operates in two modes:
64  // 'user': List deleted revs by a certain user
65  // 'all': List all deleted revs in NS
66  $mode = 'all';
67  if ( !is_null( $params['user'] ) ) {
68  $mode = 'user';
69  }
70 
71  if ( $mode == 'user' ) {
72  foreach ( [ 'from', 'to', 'prefix', 'excludeuser' ] as $param ) {
73  if ( !is_null( $params[$param] ) ) {
74  $p = $this->getModulePrefix();
75  $this->dieWithError(
76  [ 'apierror-invalidparammix-cannotusewith', $p.$param, "{$p}user" ],
77  'invalidparammix'
78  );
79  }
80  }
81  } else {
82  foreach ( [ 'start', 'end' ] as $param ) {
83  if ( !is_null( $params[$param] ) ) {
84  $p = $this->getModulePrefix();
85  $this->dieWithError(
86  [ 'apierror-invalidparammix-mustusewith', $p.$param, "{$p}user" ],
87  'invalidparammix'
88  );
89  }
90  }
91  }
92 
93  // If we're generating titles only, we can use DISTINCT for a better
94  // query. But we can't do that in 'user' mode (wrong index), and we can
95  // only do it when sorting ASC (because MySQL apparently can't use an
96  // index backwards for grouping even though it can for ORDER BY, WTF?)
97  $dir = $params['dir'];
98  $optimizeGenerateTitles = false;
99  if ( $mode === 'all' && $params['generatetitles'] && $resultPageSet !== null ) {
100  if ( $dir === 'newer' ) {
101  $optimizeGenerateTitles = true;
102  } else {
103  $p = $this->getModulePrefix();
104  $this->addWarning( [ 'apiwarn-alldeletedrevisions-performance', $p ], 'performance' );
105  }
106  }
107 
108  if ( $resultPageSet === null ) {
109  $this->parseParameters( $params );
110  $arQuery = $revisionStore->getArchiveQueryInfo();
111  $this->addTables( $arQuery['tables'] );
112  $this->addJoinConds( $arQuery['joins'] );
113  $this->addFields( $arQuery['fields'] );
114  $this->addFields( [ 'ar_title', 'ar_namespace' ] );
115  } else {
116  $this->limit = $this->getParameter( 'limit' ) ?: 10;
117  $this->addTables( 'archive' );
118  $this->addFields( [ 'ar_title', 'ar_namespace' ] );
119  if ( $optimizeGenerateTitles ) {
120  $this->addOption( 'DISTINCT' );
121  } else {
122  $this->addFields( [ 'ar_timestamp', 'ar_rev_id', 'ar_id' ] );
123  }
124  }
125 
126  if ( $this->fld_tags ) {
127  $this->addTables( 'tag_summary' );
128  $this->addJoinConds(
129  [ 'tag_summary' => [ 'LEFT JOIN', [ 'ar_rev_id=ts_rev_id' ] ] ]
130  );
131  $this->addFields( 'ts_tags' );
132  }
133 
134  if ( !is_null( $params['tag'] ) ) {
135  $this->addTables( 'change_tag' );
136  $this->addJoinConds(
137  [ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
138  );
139  $this->addWhereFld( 'ct_tag', $params['tag'] );
140  }
141 
142  if ( $this->fetchContent ) {
143  $this->addTables( 'text' );
144  $this->addJoinConds(
145  [ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
146  );
147  $this->addFields( [ 'old_text', 'old_flags' ] );
148 
149  // This also means stricter restrictions
150  $this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] );
151  }
152 
153  $miser_ns = null;
154 
155  if ( $mode == 'all' ) {
157  $this->addWhereFld( 'ar_namespace', $namespaces );
158 
159  // For from/to/prefix, we have to consider the potential
160  // transformations of the title in all specified namespaces.
161  // Generally there will be only one transformation, but wikis with
162  // some namespaces case-sensitive could have two.
163  if ( $params['from'] !== null || $params['to'] !== null ) {
164  $isDirNewer = ( $dir === 'newer' );
165  $after = ( $isDirNewer ? '>=' : '<=' );
166  $before = ( $isDirNewer ? '<=' : '>=' );
167  $where = [];
168  foreach ( $namespaces as $ns ) {
169  $w = [];
170  if ( $params['from'] !== null ) {
171  $w[] = 'ar_title' . $after .
172  $db->addQuotes( $this->titlePartToKey( $params['from'], $ns ) );
173  }
174  if ( $params['to'] !== null ) {
175  $w[] = 'ar_title' . $before .
176  $db->addQuotes( $this->titlePartToKey( $params['to'], $ns ) );
177  }
178  $w = $db->makeList( $w, LIST_AND );
179  $where[$w][] = $ns;
180  }
181  if ( count( $where ) == 1 ) {
182  $where = key( $where );
183  $this->addWhere( $where );
184  } else {
185  $where2 = [];
186  foreach ( $where as $w => $ns ) {
187  $where2[] = $db->makeList( [ $w, 'ar_namespace' => $ns ], LIST_AND );
188  }
189  $this->addWhere( $db->makeList( $where2, LIST_OR ) );
190  }
191  }
192 
193  if ( isset( $params['prefix'] ) ) {
194  $where = [];
195  foreach ( $namespaces as $ns ) {
196  $w = 'ar_title' . $db->buildLike(
197  $this->titlePartToKey( $params['prefix'], $ns ),
198  $db->anyString() );
199  $where[$w][] = $ns;
200  }
201  if ( count( $where ) == 1 ) {
202  $where = key( $where );
203  $this->addWhere( $where );
204  } else {
205  $where2 = [];
206  foreach ( $where as $w => $ns ) {
207  $where2[] = $db->makeList( [ $w, 'ar_namespace' => $ns ], LIST_AND );
208  }
209  $this->addWhere( $db->makeList( $where2, LIST_OR ) );
210  }
211  }
212  } else {
213  if ( $this->getConfig()->get( 'MiserMode' ) ) {
214  $miser_ns = $params['namespace'];
215  } else {
216  $this->addWhereFld( 'ar_namespace', $params['namespace'] );
217  }
218  $this->addTimestampWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] );
219  }
220 
221  if ( !is_null( $params['user'] ) ) {
222  // Don't query by user ID here, it might be able to use the ar_usertext_timestamp index.
223  $actorQuery = ActorMigration::newMigration()
224  ->getWhere( $db, 'ar_user', User::newFromName( $params['user'], false ), false );
225  $this->addTables( $actorQuery['tables'] );
226  $this->addJoinConds( $actorQuery['joins'] );
227  $this->addWhere( $actorQuery['conds'] );
228  } elseif ( !is_null( $params['excludeuser'] ) ) {
229  // Here there's no chance of using ar_usertext_timestamp.
230  $actorQuery = ActorMigration::newMigration()
231  ->getWhere( $db, 'ar_user', User::newFromName( $params['excludeuser'], false ) );
232  $this->addTables( $actorQuery['tables'] );
233  $this->addJoinConds( $actorQuery['joins'] );
234  $this->addWhere( 'NOT(' . $actorQuery['conds'] . ')' );
235  }
236 
237  if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
238  // Paranoia: avoid brute force searches (T19342)
239  // (shouldn't be able to get here without 'deletedhistory', but
240  // check it again just in case)
241  if ( !$user->isAllowed( 'deletedhistory' ) ) {
242  $bitmask = RevisionRecord::DELETED_USER;
243  } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
244  $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
245  } else {
246  $bitmask = 0;
247  }
248  if ( $bitmask ) {
249  $this->addWhere( $db->bitAnd( 'ar_deleted', $bitmask ) . " != $bitmask" );
250  }
251  }
252 
253  if ( !is_null( $params['continue'] ) ) {
254  $cont = explode( '|', $params['continue'] );
255  $op = ( $dir == 'newer' ? '>' : '<' );
256  if ( $optimizeGenerateTitles ) {
257  $this->dieContinueUsageIf( count( $cont ) != 2 );
258  $ns = intval( $cont[0] );
259  $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] );
260  $title = $db->addQuotes( $cont[1] );
261  $this->addWhere( "ar_namespace $op $ns OR " .
262  "(ar_namespace = $ns AND ar_title $op= $title)" );
263  } elseif ( $mode == 'all' ) {
264  $this->dieContinueUsageIf( count( $cont ) != 4 );
265  $ns = intval( $cont[0] );
266  $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] );
267  $title = $db->addQuotes( $cont[1] );
268  $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
269  $ar_id = (int)$cont[3];
270  $this->dieContinueUsageIf( strval( $ar_id ) !== $cont[3] );
271  $this->addWhere( "ar_namespace $op $ns OR " .
272  "(ar_namespace = $ns AND " .
273  "(ar_title $op $title OR " .
274  "(ar_title = $title AND " .
275  "(ar_timestamp $op $ts OR " .
276  "(ar_timestamp = $ts AND " .
277  "ar_id $op= $ar_id)))))" );
278  } else {
279  $this->dieContinueUsageIf( count( $cont ) != 2 );
280  $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
281  $ar_id = (int)$cont[1];
282  $this->dieContinueUsageIf( strval( $ar_id ) !== $cont[1] );
283  $this->addWhere( "ar_timestamp $op $ts OR " .
284  "(ar_timestamp = $ts AND " .
285  "ar_id $op= $ar_id)" );
286  }
287  }
288 
289  $this->addOption( 'LIMIT', $this->limit + 1 );
290 
291  $sort = ( $dir == 'newer' ? '' : ' DESC' );
292  $orderby = [];
293  if ( $optimizeGenerateTitles ) {
294  // Targeting index name_title_timestamp
295  if ( $params['namespace'] === null || count( array_unique( $params['namespace'] ) ) > 1 ) {
296  $orderby[] = "ar_namespace $sort";
297  }
298  $orderby[] = "ar_title $sort";
299  } elseif ( $mode == 'all' ) {
300  // Targeting index name_title_timestamp
301  if ( $params['namespace'] === null || count( array_unique( $params['namespace'] ) ) > 1 ) {
302  $orderby[] = "ar_namespace $sort";
303  }
304  $orderby[] = "ar_title $sort";
305  $orderby[] = "ar_timestamp $sort";
306  $orderby[] = "ar_id $sort";
307  } else {
308  // Targeting index usertext_timestamp
309  // 'user' is always constant.
310  $orderby[] = "ar_timestamp $sort";
311  $orderby[] = "ar_id $sort";
312  }
313  $this->addOption( 'ORDER BY', $orderby );
314 
315  $res = $this->select( __METHOD__ );
316  $pageMap = []; // Maps ns&title to array index
317  $count = 0;
318  $nextIndex = 0;
319  $generated = [];
320  foreach ( $res as $row ) {
321  if ( ++$count > $this->limit ) {
322  // We've had enough
323  if ( $optimizeGenerateTitles ) {
324  $this->setContinueEnumParameter( 'continue', "$row->ar_namespace|$row->ar_title" );
325  } elseif ( $mode == 'all' ) {
326  $this->setContinueEnumParameter( 'continue',
327  "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
328  );
329  } else {
330  $this->setContinueEnumParameter( 'continue', "$row->ar_timestamp|$row->ar_id" );
331  }
332  break;
333  }
334 
335  // Miser mode namespace check
336  if ( $miser_ns !== null && !in_array( $row->ar_namespace, $miser_ns ) ) {
337  continue;
338  }
339 
340  if ( $resultPageSet !== null ) {
341  if ( $params['generatetitles'] ) {
342  $key = "{$row->ar_namespace}:{$row->ar_title}";
343  if ( !isset( $generated[$key] ) ) {
344  $generated[$key] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
345  }
346  } else {
347  $generated[] = $row->ar_rev_id;
348  }
349  } else {
350  $revision = $revisionStore->newRevisionFromArchiveRow( $row );
351  $rev = $this->extractRevisionInfo( $revision, $row );
352 
353  if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
354  $index = $nextIndex++;
355  $pageMap[$row->ar_namespace][$row->ar_title] = $index;
356  $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
357  $a = [
358  'pageid' => $title->getArticleID(),
359  'revisions' => [ $rev ],
360  ];
361  ApiResult::setIndexedTagName( $a['revisions'], 'rev' );
363  $fit = $result->addValue( [ 'query', $this->getModuleName() ], $index, $a );
364  } else {
365  $index = $pageMap[$row->ar_namespace][$row->ar_title];
366  $fit = $result->addValue(
367  [ 'query', $this->getModuleName(), $index, 'revisions' ],
368  null, $rev );
369  }
370  if ( !$fit ) {
371  if ( $mode == 'all' ) {
372  $this->setContinueEnumParameter( 'continue',
373  "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
374  );
375  } else {
376  $this->setContinueEnumParameter( 'continue', "$row->ar_timestamp|$row->ar_id" );
377  }
378  break;
379  }
380  }
381  }
382 
383  if ( $resultPageSet !== null ) {
384  if ( $params['generatetitles'] ) {
385  $resultPageSet->populateFromTitles( $generated );
386  } else {
387  $resultPageSet->populateFromRevisionIDs( $generated );
388  }
389  } else {
390  $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'page' );
391  }
392  }
393 
394  public function getAllowedParams() {
395  $ret = parent::getAllowedParams() + [
396  'user' => [
397  ApiBase::PARAM_TYPE => 'user'
398  ],
399  'namespace' => [
400  ApiBase::PARAM_ISMULTI => true,
401  ApiBase::PARAM_TYPE => 'namespace',
402  ],
403  'start' => [
404  ApiBase::PARAM_TYPE => 'timestamp',
405  ApiBase::PARAM_HELP_MSG_INFO => [ [ 'useronly' ] ],
406  ],
407  'end' => [
408  ApiBase::PARAM_TYPE => 'timestamp',
409  ApiBase::PARAM_HELP_MSG_INFO => [ [ 'useronly' ] ],
410  ],
411  'dir' => [
413  'newer',
414  'older'
415  ],
416  ApiBase::PARAM_DFLT => 'older',
417  ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
418  ],
419  'from' => [
420  ApiBase::PARAM_HELP_MSG_INFO => [ [ 'nonuseronly' ] ],
421  ],
422  'to' => [
423  ApiBase::PARAM_HELP_MSG_INFO => [ [ 'nonuseronly' ] ],
424  ],
425  'prefix' => [
426  ApiBase::PARAM_HELP_MSG_INFO => [ [ 'nonuseronly' ] ],
427  ],
428  'excludeuser' => [
429  ApiBase::PARAM_TYPE => 'user',
430  ApiBase::PARAM_HELP_MSG_INFO => [ [ 'nonuseronly' ] ],
431  ],
432  'tag' => null,
433  'continue' => [
434  ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
435  ],
436  'generatetitles' => [
438  ],
439  ];
440 
441  if ( $this->getConfig()->get( 'MiserMode' ) ) {
443  'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
444  ];
445  $ret['namespace'][ApiBase::PARAM_HELP_MSG_APPEND] = [
446  'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
447  ];
448  }
449 
450  return $ret;
451  }
452 
453  protected function getExamplesMessages() {
454  return [
455  'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
456  => 'apihelp-query+alldeletedrevisions-example-user',
457  'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
458  => 'apihelp-query+alldeletedrevisions-example-ns-main',
459  ];
460  }
461 
462  public function getHelpUrls() {
463  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Alldeletedrevisions';
464  }
465 }
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
Definition: ApiBase.php:87
getDB()
Get the Query database connection (read-only)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1636
getResult()
Get the result object.
Definition: ApiBase.php:659
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:40
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
Definition: hooks.txt:2041
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:48
$sort
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:141
A base class for functions common to producing a list of revisions.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1972
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user...
Definition: ApiBase.php:770
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 MediaWikiServices
Definition: injection.txt:23
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
static newFromLinkTarget(LinkTarget $linkTarget)
Create a new Title from a LinkTarget.
Definition: Title.php:244
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
Definition: ApiBase.php:884
__construct(ApiQuery $query, $moduleName)
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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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 since 1.16! 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:Array with elements of the form "language:title" in the order that they will be output. & $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':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. 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:2039
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
Definition: ApiBase.php:131
static newMigration()
Static constructor.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition: design.txt:25
const LIST_AND
Definition: Defines.php:43
titlePartToKey( $titlePart, $namespace=NS_MAIN)
Convert an input title or title prefix into a dbkey.
$res
Definition: database.txt:21
dieContinueUsageIf( $condition)
Die with the &#39;badcontinue&#39; error.
Definition: ApiBase.php:2140
$params
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:949
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:539
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
Definition: ApiQuery.php:36
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1813
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:949
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
Definition: distributors.txt:9
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter...
Definition: ApiBase.php:124
const LIST_OR
Definition: Defines.php:46
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
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
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
Definition: ApiBase.php:547
addWhere( $value)
Add a set of WHERE clauses to the internal array.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1896
Query module to enumerate all deleted revisions.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:51
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
parseParameters( $params)
Parse the parameters into the various instance fields.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:588
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
run(ApiPageSet $resultPageSet=null)
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
Definition: ApiBase.php:2080
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:244