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