MediaWiki REL1_32
ApiQueryBacklinks.php
Go to the documentation of this file.
1<?php
32
36 private $rootTitle;
37
40
46 private $pageMap = [];
47 private $resultArr;
48
49 private $redirTitles = [];
50 private $continueStr = null;
51
52 // output element name, database column field prefix, database table
54 'backlinks' => [
55 'code' => 'bl',
56 'prefix' => 'pl',
57 'linktbl' => 'pagelinks',
58 'helpurl' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Backlinks',
59 ],
60 'embeddedin' => [
61 'code' => 'ei',
62 'prefix' => 'tl',
63 'linktbl' => 'templatelinks',
64 'helpurl' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Embeddedin',
65 ],
66 'imageusage' => [
67 'code' => 'iu',
68 'prefix' => 'il',
69 'linktbl' => 'imagelinks',
70 'helpurl' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Imageusage',
71 ]
72 ];
73
74 public function __construct( ApiQuery $query, $moduleName ) {
75 $settings = $this->backlinksSettings[$moduleName];
76 $prefix = $settings['prefix'];
77 $code = $settings['code'];
78 $this->resultArr = [];
79
80 parent::__construct( $query, $moduleName, $code );
81 $this->bl_ns = $prefix . '_namespace';
82 $this->bl_from = $prefix . '_from';
83 $this->bl_from_ns = $prefix . '_from_namespace';
84 $this->bl_table = $settings['linktbl'];
85 $this->bl_code = $code;
86 $this->helpUrl = $settings['helpurl'];
87
88 $this->hasNS = $moduleName !== 'imageusage';
89 if ( $this->hasNS ) {
90 $this->bl_title = $prefix . '_title';
91 $this->bl_fields = [
94 ];
95 } else {
96 $this->bl_title = $prefix . '_to';
97 $this->bl_fields = [
99 ];
100 }
101 }
102
103 public function execute() {
104 $this->run();
105 }
106
107 public function getCacheMode( $params ) {
108 return 'public';
109 }
110
111 public function executeGenerator( $resultPageSet ) {
112 $this->run( $resultPageSet );
113 }
114
119 private function runFirstQuery( $resultPageSet = null ) {
120 $this->addTables( [ $this->bl_table, 'page' ] );
121 $this->addWhere( "{$this->bl_from}=page_id" );
122 if ( is_null( $resultPageSet ) ) {
123 $this->addFields( [ 'page_id', 'page_title', 'page_namespace' ] );
124 } else {
125 $this->addFields( $resultPageSet->getPageTableFields() );
126 }
127 $this->addFields( [ 'page_is_redirect', 'from_ns' => 'page_namespace' ] );
128
129 $this->addWhereFld( $this->bl_title, $this->rootTitle->getDBkey() );
130 if ( $this->hasNS ) {
131 $this->addWhereFld( $this->bl_ns, $this->rootTitle->getNamespace() );
132 }
133 $this->addWhereFld( $this->bl_from_ns, $this->params['namespace'] );
134
135 if ( count( $this->cont ) >= 2 ) {
136 $op = $this->params['dir'] == 'descending' ? '<' : '>';
137 if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
138 $this->addWhere(
139 "{$this->bl_from_ns} $op {$this->cont[0]} OR " .
140 "({$this->bl_from_ns} = {$this->cont[0]} AND " .
141 "{$this->bl_from} $op= {$this->cont[1]})"
142 );
143 } else {
144 $this->addWhere( "{$this->bl_from} $op= {$this->cont[1]}" );
145 }
146 }
147
148 if ( $this->params['filterredir'] == 'redirects' ) {
149 $this->addWhereFld( 'page_is_redirect', 1 );
150 } elseif ( $this->params['filterredir'] == 'nonredirects' && !$this->redirect ) {
151 // T24245 - Check for !redirect, as filtering nonredirects, when
152 // getting what links to them is contradictory
153 $this->addWhereFld( 'page_is_redirect', 0 );
154 }
155
156 $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
157 $sort = ( $this->params['dir'] == 'descending' ? ' DESC' : '' );
158 $orderBy = [];
159 if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
160 $orderBy[] = $this->bl_from_ns . $sort;
161 }
162 $orderBy[] = $this->bl_from . $sort;
163 $this->addOption( 'ORDER BY', $orderBy );
164 $this->addOption( 'STRAIGHT_JOIN' );
165
166 $res = $this->select( __METHOD__ );
167 $count = 0;
168 foreach ( $res as $row ) {
169 if ( ++$count > $this->params['limit'] ) {
170 // We've reached the one extra which shows that there are
171 // additional pages to be had. Stop here...
172 // Continue string may be overridden at a later step
173 $this->continueStr = "{$row->from_ns}|{$row->page_id}";
174 break;
175 }
176
177 // Fill in continuation fields for later steps
178 if ( count( $this->cont ) < 2 ) {
179 $this->cont[] = $row->from_ns;
180 $this->cont[] = $row->page_id;
181 }
182
183 $this->pageMap[$row->page_namespace][$row->page_title] = $row->page_id;
184 $t = Title::makeTitle( $row->page_namespace, $row->page_title );
185 if ( $row->page_is_redirect ) {
186 $this->redirTitles[] = $t;
187 }
188
189 if ( is_null( $resultPageSet ) ) {
190 $a = [ 'pageid' => intval( $row->page_id ) ];
192 if ( $row->page_is_redirect ) {
193 $a['redirect'] = true;
194 }
195 // Put all the results in an array first
196 $this->resultArr[$a['pageid']] = $a;
197 } else {
198 $resultPageSet->processDbRow( $row );
199 }
200 }
201 }
202
207 private function runSecondQuery( $resultPageSet = null ) {
208 $db = $this->getDB();
209 $this->addTables( [ 'page', $this->bl_table ] );
210 $this->addWhere( "{$this->bl_from}=page_id" );
211
212 if ( is_null( $resultPageSet ) ) {
213 $this->addFields( [ 'page_id', 'page_title', 'page_namespace', 'page_is_redirect' ] );
214 } else {
215 $this->addFields( $resultPageSet->getPageTableFields() );
216 }
217
218 $this->addFields( [ $this->bl_title, 'from_ns' => 'page_namespace' ] );
219 if ( $this->hasNS ) {
220 $this->addFields( $this->bl_ns );
221 }
222
223 // We can't use LinkBatch here because $this->hasNS may be false
224 $titleWhere = [];
225 $allRedirNs = [];
226 $allRedirDBkey = [];
228 foreach ( $this->redirTitles as $t ) {
229 $redirNs = $t->getNamespace();
230 $redirDBkey = $t->getDBkey();
231 $titleWhere[] = "{$this->bl_title} = " . $db->addQuotes( $redirDBkey ) .
232 ( $this->hasNS ? " AND {$this->bl_ns} = {$redirNs}" : '' );
233 $allRedirNs[$redirNs] = true;
234 $allRedirDBkey[$redirDBkey] = true;
235 }
236 $this->addWhere( $db->makeList( $titleWhere, LIST_OR ) );
237 $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
238
239 if ( count( $this->cont ) >= 6 ) {
240 $op = $this->params['dir'] == 'descending' ? '<' : '>';
241
242 $where = "{$this->bl_from} $op= {$this->cont[5]}";
243 // Don't bother with namespace, title, or from_namespace if it's
244 // otherwise constant in the where clause.
245 if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
246 $where = "{$this->bl_from_ns} $op {$this->cont[4]} OR " .
247 "({$this->bl_from_ns} = {$this->cont[4]} AND ($where))";
248 }
249 if ( count( $allRedirDBkey ) > 1 ) {
250 $title = $db->addQuotes( $this->cont[3] );
251 $where = "{$this->bl_title} $op $title OR " .
252 "({$this->bl_title} = $title AND ($where))";
253 }
254 if ( $this->hasNS && count( $allRedirNs ) > 1 ) {
255 $where = "{$this->bl_ns} $op {$this->cont[2]} OR " .
256 "({$this->bl_ns} = {$this->cont[2]} AND ($where))";
257 }
258
259 $this->addWhere( $where );
260 }
261 if ( $this->params['filterredir'] == 'redirects' ) {
262 $this->addWhereFld( 'page_is_redirect', 1 );
263 } elseif ( $this->params['filterredir'] == 'nonredirects' ) {
264 $this->addWhereFld( 'page_is_redirect', 0 );
265 }
266
267 $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
268 $orderBy = [];
269 $sort = ( $this->params['dir'] == 'descending' ? ' DESC' : '' );
270 // Don't order by namespace/title/from_namespace if it's constant in the WHERE clause
271 if ( $this->hasNS && count( $allRedirNs ) > 1 ) {
272 $orderBy[] = $this->bl_ns . $sort;
273 }
274 if ( count( $allRedirDBkey ) > 1 ) {
275 $orderBy[] = $this->bl_title . $sort;
276 }
277 if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
278 $orderBy[] = $this->bl_from_ns . $sort;
279 }
280 $orderBy[] = $this->bl_from . $sort;
281 $this->addOption( 'ORDER BY', $orderBy );
282 $this->addOption( 'USE INDEX', [ 'page' => 'PRIMARY' ] );
283
284 $res = $this->select( __METHOD__ );
285 $count = 0;
286 foreach ( $res as $row ) {
287 $ns = $this->hasNS ? $row->{$this->bl_ns} : NS_FILE;
288
289 if ( ++$count > $this->params['limit'] ) {
290 // We've reached the one extra which shows that there are
291 // additional pages to be had. Stop here...
292 // Note we must keep the parameters for the first query constant
293 // This may be overridden at a later step
294 $title = $row->{$this->bl_title};
295 $this->continueStr = implode( '|', array_slice( $this->cont, 0, 2 ) ) .
296 "|$ns|$title|{$row->from_ns}|{$row->page_id}";
297 break;
298 }
299
300 // Fill in continuation fields for later steps
301 if ( count( $this->cont ) < 6 ) {
302 $this->cont[] = $ns;
303 $this->cont[] = $row->{$this->bl_title};
304 $this->cont[] = $row->from_ns;
305 $this->cont[] = $row->page_id;
306 }
307
308 if ( is_null( $resultPageSet ) ) {
309 $a['pageid'] = intval( $row->page_id );
310 ApiQueryBase::addTitleInfo( $a, Title::makeTitle( $row->page_namespace, $row->page_title ) );
311 if ( $row->page_is_redirect ) {
312 $a['redirect'] = true;
313 }
314 $parentID = $this->pageMap[$ns][$row->{$this->bl_title}];
315 // Put all the results in an array first
316 $this->resultArr[$parentID]['redirlinks'][$row->page_id] = $a;
317 } else {
318 $resultPageSet->processDbRow( $row );
319 }
320 }
321 }
322
327 private function run( $resultPageSet = null ) {
328 $this->params = $this->extractRequestParams( false );
329 $this->redirect = isset( $this->params['redirect'] ) && $this->params['redirect'];
330 $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1 / 2 : ApiBase::LIMIT_BIG1 );
331 $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 );
332
333 $result = $this->getResult();
334
335 if ( $this->params['limit'] == 'max' ) {
336 $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
337 $result->addParsedLimit( $this->getModuleName(), $this->params['limit'] );
338 } else {
339 $this->params['limit'] = intval( $this->params['limit'] );
340 $this->validateLimit( 'limit', $this->params['limit'], 1, $userMax, $botMax );
341 }
342
343 $this->rootTitle = $this->getTitleFromTitleOrPageId( $this->params );
344
345 // only image titles are allowed for the root in imageinfo mode
346 if ( !$this->hasNS && $this->rootTitle->getNamespace() !== NS_FILE ) {
347 $this->dieWithError(
348 [ 'apierror-imageusage-badtitle', $this->getModuleName() ],
349 'bad_image_title'
350 );
351 }
352
353 // Parse and validate continuation parameter
354 $this->cont = [];
355 if ( $this->params['continue'] !== null ) {
356 $cont = explode( '|', $this->params['continue'] );
357
358 switch ( count( $cont ) ) {
359 case 8:
360 // redirect page ID for result adding
361 $this->cont[7] = (int)$cont[7];
362 $this->dieContinueUsageIf( $cont[7] !== (string)$this->cont[7] );
363
364 /* Fall through */
365
366 case 7:
367 // top-level page ID for result adding
368 $this->cont[6] = (int)$cont[6];
369 $this->dieContinueUsageIf( $cont[6] !== (string)$this->cont[6] );
370
371 /* Fall through */
372
373 case 6:
374 // ns for 2nd query (even for imageusage)
375 $this->cont[2] = (int)$cont[2];
376 $this->dieContinueUsageIf( $cont[2] !== (string)$this->cont[2] );
377
378 // title for 2nd query
379 $this->cont[3] = $cont[3];
380
381 // from_ns for 2nd query
382 $this->cont[4] = (int)$cont[4];
383 $this->dieContinueUsageIf( $cont[4] !== (string)$this->cont[4] );
384
385 // from_id for 1st query
386 $this->cont[5] = (int)$cont[5];
387 $this->dieContinueUsageIf( $cont[5] !== (string)$this->cont[5] );
388
389 /* Fall through */
390
391 case 2:
392 // from_ns for 1st query
393 $this->cont[0] = (int)$cont[0];
394 $this->dieContinueUsageIf( $cont[0] !== (string)$this->cont[0] );
395
396 // from_id for 1st query
397 $this->cont[1] = (int)$cont[1];
398 $this->dieContinueUsageIf( $cont[1] !== (string)$this->cont[1] );
399
400 break;
401
402 default:
403 $this->dieContinueUsageIf( true );
404 }
405
406 ksort( $this->cont );
407 }
408
409 $this->runFirstQuery( $resultPageSet );
410 if ( $this->redirect && count( $this->redirTitles ) ) {
411 $this->resetQueryParams();
412 $this->runSecondQuery( $resultPageSet );
413 }
414
415 // Fill in any missing fields in case it's needed below
416 $this->cont += [ 0, 0, 0, '', 0, 0, 0 ];
417
418 if ( is_null( $resultPageSet ) ) {
419 // Try to add the result data in one go and pray that it fits
420 $code = $this->bl_code;
421 $data = array_map( function ( $arr ) use ( $result, $code ) {
422 if ( isset( $arr['redirlinks'] ) ) {
423 $arr['redirlinks'] = array_values( $arr['redirlinks'] );
424 ApiResult::setIndexedTagName( $arr['redirlinks'], $code );
425 }
426 return $arr;
427 }, array_values( $this->resultArr ) );
428 $fit = $result->addValue( 'query', $this->getModuleName(), $data );
429 if ( !$fit ) {
430 // It didn't fit. Add elements one by one until the
431 // result is full.
432 ksort( $this->resultArr );
433 if ( count( $this->cont ) >= 7 ) {
434 $startAt = $this->cont[6];
435 } else {
436 reset( $this->resultArr );
437 $startAt = key( $this->resultArr );
438 }
439 $idx = 0;
440 foreach ( $this->resultArr as $pageID => $arr ) {
441 if ( $pageID < $startAt ) {
442 continue;
443 }
444
445 // Add the basic entry without redirlinks first
446 $fit = $result->addValue(
447 [ 'query', $this->getModuleName() ],
448 $idx, array_diff_key( $arr, [ 'redirlinks' => '' ] ) );
449 if ( !$fit ) {
450 $this->continueStr = implode( '|', array_slice( $this->cont, 0, 6 ) ) .
451 "|$pageID";
452 break;
453 }
454
455 $hasRedirs = false;
456 $redirLinks = isset( $arr['redirlinks'] ) ? (array)$arr['redirlinks'] : [];
457 ksort( $redirLinks );
458 if ( count( $this->cont ) >= 8 && $pageID == $startAt ) {
459 $redirStartAt = $this->cont[7];
460 } else {
461 reset( $redirLinks );
462 $redirStartAt = key( $redirLinks );
463 }
464 foreach ( $redirLinks as $key => $redir ) {
465 if ( $key < $redirStartAt ) {
466 continue;
467 }
468
469 $fit = $result->addValue(
470 [ 'query', $this->getModuleName(), $idx, 'redirlinks' ],
471 null, $redir );
472 if ( !$fit ) {
473 $this->continueStr = implode( '|', array_slice( $this->cont, 0, 6 ) ) .
474 "|$pageID|$key";
475 break;
476 }
477 $hasRedirs = true;
478 }
479 if ( $hasRedirs ) {
480 $result->addIndexedTagName(
481 [ 'query', $this->getModuleName(), $idx, 'redirlinks' ],
482 $this->bl_code );
483 }
484 if ( !$fit ) {
485 break;
486 }
487
488 $idx++;
489 }
490 }
491
492 $result->addIndexedTagName(
493 [ 'query', $this->getModuleName() ],
494 $this->bl_code
495 );
496 }
497 if ( !is_null( $this->continueStr ) ) {
498 $this->setContinueEnumParameter( 'continue', $this->continueStr );
499 }
500 }
501
502 public function getAllowedParams() {
503 $retval = [
504 'title' => [
505 ApiBase::PARAM_TYPE => 'string',
506 ],
507 'pageid' => [
508 ApiBase::PARAM_TYPE => 'integer',
509 ],
510 'continue' => [
511 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
512 ],
513 'namespace' => [
515 ApiBase::PARAM_TYPE => 'namespace'
516 ],
517 'dir' => [
518 ApiBase::PARAM_DFLT => 'ascending',
520 'ascending',
521 'descending'
522 ]
523 ],
524 'filterredir' => [
525 ApiBase::PARAM_DFLT => 'all',
527 'all',
528 'redirects',
529 'nonredirects'
530 ]
531 ],
532 'limit' => [
534 ApiBase::PARAM_TYPE => 'limit',
538 ]
539 ];
540 if ( $this->getModuleName() == 'embeddedin' ) {
541 return $retval;
542 }
543 $retval['redirect'] = false;
544
545 return $retval;
546 }
547
548 protected function getExamplesMessages() {
549 static $examples = [
550 'backlinks' => [
551 'action=query&list=backlinks&bltitle=Main%20Page'
552 => 'apihelp-query+backlinks-example-simple',
553 'action=query&generator=backlinks&gbltitle=Main%20Page&prop=info'
554 => 'apihelp-query+backlinks-example-generator',
555 ],
556 'embeddedin' => [
557 'action=query&list=embeddedin&eititle=Template:Stub'
558 => 'apihelp-query+embeddedin-example-simple',
559 'action=query&generator=embeddedin&geititle=Template:Stub&prop=info'
560 => 'apihelp-query+embeddedin-example-generator',
561 ],
562 'imageusage' => [
563 'action=query&list=imageusage&iutitle=File:Albert%20Einstein%20Head.jpg'
564 => 'apihelp-query+imageusage-example-simple',
565 'action=query&generator=imageusage&giutitle=File:Albert%20Einstein%20Head.jpg&prop=info'
566 => 'apihelp-query+imageusage-example-generator',
567 ]
568 ];
569
570 return $examples[$this->getModuleName()];
571 }
572
573 public function getHelpUrls() {
574 return $this->helpUrl;
575 }
576}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second redirect
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition ApiBase.php:96
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:90
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition ApiBase.php:87
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition ApiBase.php:48
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:99
const LIMIT_BIG1
Fast query, standard limit.
Definition ApiBase.php:252
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:124
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition ApiBase.php:254
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition ApiBase.php:51
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
addWhere( $value)
Add a set of WHERE clauses to the internal array.
This is the main query class.
Definition ApiQuery.php:36
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Represents a title within MediaWiki.
Definition Title.php:39
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 select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
$res
Definition database.txt:21
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 NS_FILE
Definition Defines.php:70
const LIST_OR
Definition Defines.php:46
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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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:2042
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 incomplete not yet checked for validity & $retval
Definition hooks.txt:266
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
Definition hooks.txt:2214
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
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 & $code
Definition hooks.txt:895
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:1656
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:37
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))
$sort