MediaWiki  master
QueryPage.php
Go to the documentation of this file.
1 <?php
28 
35 abstract class QueryPage extends SpecialPage {
37  protected $listoutput = false;
38 
40  protected $offset = 0;
41 
43  protected $limit = 0;
44 
52  protected $numRows;
53 
57  protected $cachedTimestamp = null;
58 
62  protected $shownavigation = true;
63 
73  public static function getPages() {
74  static $qp = null;
75 
76  if ( $qp === null ) {
77  // QueryPage subclass, Special page name
78  $qp = [
79  [ AncientPagesPage::class, 'Ancientpages' ],
80  [ BrokenRedirectsPage::class, 'BrokenRedirects' ],
81  [ DeadendPagesPage::class, 'Deadendpages' ],
82  [ DoubleRedirectsPage::class, 'DoubleRedirects' ],
83  [ FileDuplicateSearchPage::class, 'FileDuplicateSearch' ],
84  [ ListDuplicatedFilesPage::class, 'ListDuplicatedFiles' ],
85  [ LinkSearchPage::class, 'LinkSearch' ],
86  [ ListredirectsPage::class, 'Listredirects' ],
87  [ LonelyPagesPage::class, 'Lonelypages' ],
88  [ LongPagesPage::class, 'Longpages' ],
89  [ MediaStatisticsPage::class, 'MediaStatistics' ],
90  [ MIMEsearchPage::class, 'MIMEsearch' ],
91  [ MostcategoriesPage::class, 'Mostcategories' ],
92  [ MostimagesPage::class, 'Mostimages' ],
93  [ MostinterwikisPage::class, 'Mostinterwikis' ],
94  [ MostlinkedCategoriesPage::class, 'Mostlinkedcategories' ],
95  [ MostlinkedTemplatesPage::class, 'Mostlinkedtemplates' ],
96  [ MostlinkedPage::class, 'Mostlinked' ],
97  [ MostrevisionsPage::class, 'Mostrevisions' ],
98  [ FewestrevisionsPage::class, 'Fewestrevisions' ],
99  [ ShortPagesPage::class, 'Shortpages' ],
100  [ UncategorizedCategoriesPage::class, 'Uncategorizedcategories' ],
101  [ UncategorizedPagesPage::class, 'Uncategorizedpages' ],
102  [ UncategorizedImagesPage::class, 'Uncategorizedimages' ],
103  [ UncategorizedTemplatesPage::class, 'Uncategorizedtemplates' ],
104  [ UnusedCategoriesPage::class, 'Unusedcategories' ],
105  [ UnusedimagesPage::class, 'Unusedimages' ],
106  [ WantedCategoriesPage::class, 'Wantedcategories' ],
107  [ WantedFilesPage::class, 'Wantedfiles' ],
108  [ WantedPagesPage::class, 'Wantedpages' ],
109  [ WantedTemplatesPage::class, 'Wantedtemplates' ],
110  [ UnwatchedpagesPage::class, 'Unwatchedpages' ],
111  [ UnusedtemplatesPage::class, 'Unusedtemplates' ],
112  [ WithoutInterwikiPage::class, 'Withoutinterwiki' ],
113  ];
114  Hooks::run( 'wgQueryPages', [ &$qp ] );
115  }
116 
117  return $qp;
118  }
119 
125  function setListoutput( $bool ) {
126  $this->listoutput = $bool;
127  }
128 
155  public function getQueryInfo() {
156  return null;
157  }
158 
165  function getSQL() {
166  /* Implement getQueryInfo() instead */
167  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
168  . "getQuery() properly" );
169  }
170 
178  function getOrderFields() {
179  return [ 'value' ];
180  }
181 
192  public function usesTimestamps() {
193  return false;
194  }
195 
201  function sortDescending() {
202  return true;
203  }
204 
212  public function isExpensive() {
213  return $this->getConfig()->get( 'DisableQueryPages' );
214  }
215 
223  public function isCacheable() {
224  return true;
225  }
226 
233  public function isCached() {
234  return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
235  }
236 
242  function isSyndicated() {
243  return true;
244  }
245 
255  abstract function formatResult( $skin, $result );
256 
262  function getPageHeader() {
263  return '';
264  }
265 
273  protected function showEmptyText() {
274  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
275  }
276 
284  function linkParameters() {
285  return [];
286  }
287 
296  public function recache( $limit, $ignoreErrors = true ) {
297  if ( !$this->isCacheable() ) {
298  return 0;
299  }
300 
301  $fname = static::class . '::recache';
302  $dbw = wfGetDB( DB_MASTER );
303  if ( !$dbw ) {
304  return false;
305  }
306 
307  try {
308  # Do query
309  $res = $this->reallyDoQuery( $limit, false );
310  $num = false;
311  if ( $res ) {
312  $num = $res->numRows();
313  # Fetch results
314  $vals = [];
315  foreach ( $res as $row ) {
316  if ( isset( $row->value ) ) {
317  if ( $this->usesTimestamps() ) {
318  $value = wfTimestamp( TS_UNIX,
319  $row->value );
320  } else {
321  $value = intval( $row->value ); // T16414
322  }
323  } else {
324  $value = 0;
325  }
326 
327  $vals[] = [
328  'qc_type' => $this->getName(),
329  'qc_namespace' => $row->namespace,
330  'qc_title' => $row->title,
331  'qc_value' => $value
332  ];
333  }
334 
335  $dbw->doAtomicSection(
336  __METHOD__,
337  function ( IDatabase $dbw, $fname ) use ( $vals ) {
338  # Clear out any old cached data
339  $dbw->delete( 'querycache',
340  [ 'qc_type' => $this->getName() ],
341  $fname
342  );
343  # Save results into the querycache table on the master
344  if ( count( $vals ) ) {
345  $dbw->insert( 'querycache', $vals, $fname );
346  }
347  # Update the querycache_info record for the page
348  $dbw->delete( 'querycache_info',
349  [ 'qci_type' => $this->getName() ],
350  $fname
351  );
352  $dbw->insert( 'querycache_info',
353  [ 'qci_type' => $this->getName(),
354  'qci_timestamp' => $dbw->timestamp() ],
355  $fname
356  );
357  }
358  );
359  }
360  } catch ( DBError $e ) {
361  if ( !$ignoreErrors ) {
362  throw $e; // report query error
363  }
364  $num = false; // set result to false to indicate error
365  }
366 
367  return $num;
368  }
369 
374  function getRecacheDB() {
375  return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
376  }
377 
385  public function reallyDoQuery( $limit, $offset = false ) {
386  $fname = static::class . '::reallyDoQuery';
387  $dbr = $this->getRecacheDB();
388  $query = $this->getQueryInfo();
389  $order = $this->getOrderFields();
390 
391  if ( $this->sortDescending() ) {
392  foreach ( $order as &$field ) {
393  $field .= ' DESC';
394  }
395  }
396 
397  if ( is_array( $query ) ) {
398  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
399  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
400  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
401  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
402  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
403 
404  if ( $order ) {
405  $options['ORDER BY'] = $order;
406  }
407 
408  if ( $limit !== false ) {
409  $options['LIMIT'] = intval( $limit );
410  }
411 
412  if ( $offset !== false ) {
413  $options['OFFSET'] = intval( $offset );
414  }
415 
416  $res = $dbr->select( $tables, $fields, $conds, $fname,
417  $options, $join_conds
418  );
419  } else {
420  // Old-fashioned raw SQL style, deprecated
421  $sql = $this->getSQL();
422  $sql .= ' ORDER BY ' . implode( ', ', $order );
423  $sql = $dbr->limitResult( $sql, $limit, $offset );
424  $res = $dbr->query( $sql, $fname );
425  }
426 
427  return $res;
428  }
429 
436  public function doQuery( $offset = false, $limit = false ) {
437  if ( $this->isCached() && $this->isCacheable() ) {
438  return $this->fetchFromCache( $limit, $offset );
439  } else {
440  return $this->reallyDoQuery( $limit, $offset );
441  }
442  }
443 
451  public function fetchFromCache( $limit, $offset = false ) {
452  $dbr = wfGetDB( DB_REPLICA );
453  $options = [];
454 
455  if ( $limit !== false ) {
456  $options['LIMIT'] = intval( $limit );
457  }
458 
459  if ( $offset !== false ) {
460  $options['OFFSET'] = intval( $offset );
461  }
462 
463  $order = $this->getCacheOrderFields();
464  if ( $this->sortDescending() ) {
465  foreach ( $order as &$field ) {
466  $field .= " DESC";
467  }
468  }
469  if ( $order ) {
470  $options['ORDER BY'] = $order;
471  }
472 
473  return $dbr->select( 'querycache',
474  [ 'qc_type',
475  'namespace' => 'qc_namespace',
476  'title' => 'qc_title',
477  'value' => 'qc_value' ],
478  [ 'qc_type' => $this->getName() ],
479  __METHOD__,
480  $options
481  );
482  }
483 
490  function getCacheOrderFields() {
491  return [ 'value' ];
492  }
493 
497  public function getCachedTimestamp() {
498  if ( is_null( $this->cachedTimestamp ) ) {
499  $dbr = wfGetDB( DB_REPLICA );
500  $fname = static::class . '::getCachedTimestamp';
501  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
502  [ 'qci_type' => $this->getName() ], $fname );
503  }
504  return $this->cachedTimestamp;
505  }
506 
519  protected function getLimitOffset() {
520  list( $limit, $offset ) = $this->getRequest()->getLimitOffset();
521  if ( $this->getConfig()->get( 'MiserMode' ) ) {
522  $maxResults = $this->getMaxResults();
523  // Can't display more than max results on a page
524  $limit = min( $limit, $maxResults );
525  // Can't skip over more than the end of $maxResults
526  $offset = min( $offset, $maxResults + 1 );
527  }
528  return [ $limit, $offset ];
529  }
530 
539  protected function getDBLimit( $uiLimit, $uiOffset ) {
540  $maxResults = $this->getMaxResults();
541  if ( $this->getConfig()->get( 'MiserMode' ) ) {
542  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
543  return max( $limit, 0 );
544  } else {
545  return $uiLimit + 1;
546  }
547  }
548 
558  protected function getMaxResults() {
559  // Max of 10000, unless we store more than 10000 in query cache.
560  return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
561  }
562 
568  public function execute( $par ) {
569  $user = $this->getUser();
570  if ( !$this->userCanExecute( $user ) ) {
571  $this->displayRestrictionError();
572  return;
573  }
574 
575  $this->setHeaders();
576  $this->outputHeader();
577 
578  $out = $this->getOutput();
579 
580  if ( $this->isCached() && !$this->isCacheable() ) {
581  $out->addWikiMsg( 'querypage-disabled' );
582  return;
583  }
584 
585  $out->setSyndicated( $this->isSyndicated() );
586 
587  if ( $this->limit == 0 && $this->offset == 0 ) {
588  list( $this->limit, $this->offset ) = $this->getLimitOffset();
589  }
590  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
591  // @todo Use doQuery()
592  if ( !$this->isCached() ) {
593  # select one extra row for navigation
594  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
595  } else {
596  # Get the cached result, select one extra row for navigation
597  $res = $this->fetchFromCache( $dbLimit, $this->offset );
598  if ( !$this->listoutput ) {
599  # Fetch the timestamp of this update
600  $ts = $this->getCachedTimestamp();
601  $lang = $this->getLanguage();
602  $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
603 
604  if ( $ts ) {
605  $updated = $lang->userTimeAndDate( $ts, $user );
606  $updateddate = $lang->userDate( $ts, $user );
607  $updatedtime = $lang->userTime( $ts, $user );
608  $out->addMeta( 'Data-Cache-Time', $ts );
609  $out->addJsConfigVars( 'dataCacheTime', $ts );
610  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
611  } else {
612  $out->addWikiMsg( 'perfcached', $maxResults );
613  }
614 
615  # If updates on this page have been disabled, let the user know
616  # that the data set won't be refreshed for now
617  if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
618  && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
619  ) {
620  $out->wrapWikiMsg(
621  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
622  'querypage-no-updates'
623  );
624  }
625  }
626  }
627 
628  $this->numRows = $res->numRows();
629 
630  $dbr = $this->getRecacheDB();
631  $this->preprocessResults( $dbr, $res );
632 
633  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
634 
635  # Top header and navigation
636  if ( $this->shownavigation ) {
637  $out->addHTML( $this->getPageHeader() );
638  if ( $this->numRows > 0 ) {
639  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
640  min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
641  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
642  # Disable the "next" link when we reach the end
643  $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
644  && ( $this->offset + $this->limit >= $this->getMaxResults() );
645  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
646  $paging = $this->buildPrevNextNavigation( $this->offset,
647  $this->limit, $this->linkParameters(), $atEnd, $par );
648  $out->addHTML( '<p>' . $paging . '</p>' );
649  } else {
650  # No results to show, so don't bother with "showing X of Y" etc.
651  # -- just let the user know and give up now
652  $this->showEmptyText();
653  $out->addHTML( Xml::closeElement( 'div' ) );
654  return;
655  }
656  }
657 
658  # The actual results; specialist subclasses will want to handle this
659  # with more than a straight list, so we hand them the info, plus
660  # an OutputPage, and let them get on with it
661  $this->outputResults( $out,
662  $this->getSkin(),
663  $dbr, # Should use a ResultWrapper for this
664  $res,
665  min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
666  $this->offset );
667 
668  # Repeat the paging links at the bottom
669  if ( $this->shownavigation ) {
670  $out->addHTML( '<p>' . $paging . '</p>' );
671  }
672 
673  $out->addHTML( Xml::closeElement( 'div' ) );
674  }
675 
687  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
688  if ( $num > 0 ) {
689  $html = [];
690  if ( !$this->listoutput ) {
691  $html[] = $this->openList( $offset );
692  }
693 
694  # $res might contain the whole 1,000 rows, so we read up to
695  # $num [should update this to use a Pager]
696  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
697  $line = $this->formatResult( $skin, $row );
698  if ( $line ) {
699  $html[] = $this->listoutput
700  ? $line
701  : "<li>{$line}</li>\n";
702  }
703  }
704 
705  if ( !$this->listoutput ) {
706  $html[] = $this->closeList();
707  }
708 
709  $html = $this->listoutput
710  ? MediaWikiServices::getInstance()->getContentLanguage()->listToText( $html )
711  : implode( '', $html );
712 
713  $out->addHTML( $html );
714  }
715  }
716 
721  function openList( $offset ) {
722  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
723  }
724 
728  function closeList() {
729  return "</ol>\n";
730  }
731 
737  function preprocessResults( $db, $res ) {
738  }
739 
750  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
751  if ( !$res->numRows() ) {
752  return;
753  }
754 
755  $batch = new LinkBatch;
756  foreach ( $res as $row ) {
757  $batch->add( $ns ?? $row->namespace, $row->title );
758  }
759  $batch->execute();
760 
761  $res->seek( 0 );
762  }
763 }
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))
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:568
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 just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1982
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
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:1585
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: QueryPage.php:687
bool $shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:62
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2159
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:436
if(!isset( $args[0])) $lang
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:178
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:558
$value
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:233
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:451
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
getOutput()
Get the OutputPage being used for this instance.
const DB_MASTER
Definition: defines.php:26
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:979
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
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. '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 '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:1980
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:273
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
Definition: QueryPage.php:519
$batch
Definition: linkcache.txt:23
This is a class for doing query pages; since they&#39;re almost all the same, we factor out some of the f...
Definition: QueryPage.php:35
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 $out
Definition: hooks.txt:780
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
openList( $offset)
Definition: QueryPage.php:721
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:374
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array...
Definition: QueryPage.php:284
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:108
displayRestrictionError()
Output an error message telling the user what access level they have to have.
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:737
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:385
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:155
$res
Definition: database.txt:21
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:539
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:201
Result wrapper for grabbing data queried from an IDatabase object.
getSkin()
Shortcut to get the skin being used for this instance.
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 & $options
Definition: hooks.txt:1982
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:40
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:262
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
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 just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition: hooks.txt:1982
numRows()
Get the number of rows in a result object.
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
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings, LocalSettings).
Definition: Setup.php:123
int $numRows
The number of rows returned by the query.
Definition: QueryPage.php:52
seek( $pos)
Change the position of the cursor in a result object.
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
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:117
getName()
Get the name of this Special Page.
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
getCacheOrderFields()
Return the order fields for fetchFromCache.
Definition: QueryPage.php:490
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:125
getUser()
Shortcut to get the User executing this instance.
$line
Definition: cdb.php:59
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition: QueryPage.php:37
getConfig()
Shortcut to get main config object.
int $limit
Definition: QueryPage.php:43
getLanguage()
Shortcut to get user&#39;s language.
msg( $key)
Wrapper around wfMessage that sets the current context.
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
usesTimestamps()
Does this query return timestamps rather than integers in its &#39;value&#39; field? If true, this class will convert &#39;value&#39; to a UNIX timestamp for caching.
Definition: QueryPage.php:192
getCachedTimestamp()
Definition: QueryPage.php:497
const DB_REPLICA
Definition: defines.php:25
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include title and ...
Definition: QueryPage.php:750
getRequest()
Get the WebRequest being used for this instance.
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:165
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don&#39;t let it run in miser mode...
Definition: QueryPage.php:212
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:223
delete( $table, $conds, $fname=__METHOD__)
DELETE query wrapper.
string null $cachedTimestamp
Definition: QueryPage.php:57
formatResult( $skin, $result)
Formats the results of the query for display.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:296
Database error base class.
Definition: DBError.php:30
isSyndicated()
Sometime we don&#39;t want to build rss / atom feeds.
Definition: QueryPage.php:242
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates...
Definition: QueryPage.php:73
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1641
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200