MediaWiki  master
QueryPage.php
Go to the documentation of this file.
1 <?php
29 
36 abstract class QueryPage extends SpecialPage {
38  protected $listoutput = false;
39 
41  protected $offset = 0;
42 
44  protected $limit = 0;
45 
53  protected $numRows;
54 
58  protected $cachedTimestamp = null;
59 
63  protected $shownavigation = true;
64 
74  public static function getPages() {
75  static $qp = null;
76 
77  if ( $qp === null ) {
78  // QueryPage subclass, Special page name
79  $qp = [
80  [ AncientPagesPage::class, 'Ancientpages' ],
81  [ BrokenRedirectsPage::class, 'BrokenRedirects' ],
82  [ DeadendPagesPage::class, 'Deadendpages' ],
83  [ DoubleRedirectsPage::class, 'DoubleRedirects' ],
84  [ FileDuplicateSearchPage::class, 'FileDuplicateSearch' ],
85  [ ListDuplicatedFilesPage::class, 'ListDuplicatedFiles' ],
86  [ LinkSearchPage::class, 'LinkSearch' ],
87  [ ListredirectsPage::class, 'Listredirects' ],
88  [ LonelyPagesPage::class, 'Lonelypages' ],
89  [ LongPagesPage::class, 'Longpages' ],
90  [ MediaStatisticsPage::class, 'MediaStatistics' ],
91  [ MIMEsearchPage::class, 'MIMEsearch' ],
92  [ MostcategoriesPage::class, 'Mostcategories' ],
93  [ MostimagesPage::class, 'Mostimages' ],
94  [ MostinterwikisPage::class, 'Mostinterwikis' ],
95  [ MostlinkedCategoriesPage::class, 'Mostlinkedcategories' ],
96  [ MostlinkedTemplatesPage::class, 'Mostlinkedtemplates' ],
97  [ MostlinkedPage::class, 'Mostlinked' ],
98  [ MostrevisionsPage::class, 'Mostrevisions' ],
99  [ FewestrevisionsPage::class, 'Fewestrevisions' ],
100  [ ShortPagesPage::class, 'Shortpages' ],
101  [ UncategorizedCategoriesPage::class, 'Uncategorizedcategories' ],
102  [ UncategorizedPagesPage::class, 'Uncategorizedpages' ],
103  [ UncategorizedImagesPage::class, 'Uncategorizedimages' ],
104  [ UncategorizedTemplatesPage::class, 'Uncategorizedtemplates' ],
105  [ UnusedCategoriesPage::class, 'Unusedcategories' ],
106  [ UnusedimagesPage::class, 'Unusedimages' ],
107  [ WantedCategoriesPage::class, 'Wantedcategories' ],
108  [ WantedFilesPage::class, 'Wantedfiles' ],
109  [ WantedPagesPage::class, 'Wantedpages' ],
110  [ WantedTemplatesPage::class, 'Wantedtemplates' ],
111  [ UnwatchedpagesPage::class, 'Unwatchedpages' ],
112  [ UnusedtemplatesPage::class, 'Unusedtemplates' ],
113  [ WithoutInterwikiPage::class, 'Withoutinterwiki' ],
114  ];
115  Hooks::run( 'wgQueryPages', [ &$qp ] );
116  }
117 
118  return $qp;
119  }
120 
126  function setListoutput( $bool ) {
127  $this->listoutput = $bool;
128  }
129 
156  public function getQueryInfo() {
157  return null;
158  }
159 
166  function getSQL() {
167  /* Implement getQueryInfo() instead */
168  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
169  . "getQuery() properly" );
170  }
171 
179  function getOrderFields() {
180  return [ 'value' ];
181  }
182 
193  public function usesTimestamps() {
194  return false;
195  }
196 
202  function sortDescending() {
203  return true;
204  }
205 
213  public function isExpensive() {
214  return $this->getConfig()->get( 'DisableQueryPages' );
215  }
216 
224  public function isCacheable() {
225  return true;
226  }
227 
234  public function isCached() {
235  return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
236  }
237 
243  function isSyndicated() {
244  return true;
245  }
246 
256  abstract function formatResult( $skin, $result );
257 
263  function getPageHeader() {
264  return '';
265  }
266 
274  protected function showEmptyText() {
275  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
276  }
277 
285  function linkParameters() {
286  return [];
287  }
288 
297  public function recache( $limit, $ignoreErrors = true ) {
298  if ( !$this->isCacheable() ) {
299  return 0;
300  }
301 
302  $fname = static::class . '::recache';
303  $dbw = wfGetDB( DB_MASTER );
304  if ( !$dbw ) {
305  return false;
306  }
307 
308  try {
309  # Do query
310  $res = $this->reallyDoQuery( $limit, false );
311  $num = false;
312  if ( $res ) {
313  $num = $res->numRows();
314  # Fetch results
315  $vals = [];
316  foreach ( $res as $i => $row ) {
317  if ( isset( $row->value ) ) {
318  if ( $this->usesTimestamps() ) {
319  $value = wfTimestamp( TS_UNIX,
320  $row->value );
321  } else {
322  $value = intval( $row->value ); // T16414
323  }
324  } else {
325  $value = $i;
326  }
327 
328  $vals[] = [
329  'qc_type' => $this->getName(),
330  'qc_namespace' => $row->namespace,
331  'qc_title' => $row->title,
332  'qc_value' => $value
333  ];
334  }
335 
336  $dbw->doAtomicSection(
337  __METHOD__,
338  function ( IDatabase $dbw, $fname ) use ( $vals ) {
339  # Clear out any old cached data
340  $dbw->delete( 'querycache',
341  [ 'qc_type' => $this->getName() ],
342  $fname
343  );
344  # Save results into the querycache table on the master
345  if ( count( $vals ) ) {
346  $dbw->insert( 'querycache', $vals, $fname );
347  }
348  # Update the querycache_info record for the page
349  $dbw->delete( 'querycache_info',
350  [ 'qci_type' => $this->getName() ],
351  $fname
352  );
353  $dbw->insert( 'querycache_info',
354  [ 'qci_type' => $this->getName(),
355  'qci_timestamp' => $dbw->timestamp() ],
356  $fname
357  );
358  }
359  );
360  }
361  } catch ( DBError $e ) {
362  if ( !$ignoreErrors ) {
363  throw $e; // report query error
364  }
365  $num = false; // set result to false to indicate error
366  }
367 
368  return $num;
369  }
370 
375  function getRecacheDB() {
376  return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
377  }
378 
385  public function delete( LinkTarget $title ) {
386  if ( $this->isCached() ) {
387  $dbw = wfGetDB( DB_MASTER );
388  $dbw->delete( 'querycache', [
389  'qc_type' => $this->getName(),
390  'qc_namespace' => $title->getNamespace(),
391  'qc_title' => $title->getDBkey(),
392  ], __METHOD__ );
393  }
394  }
395 
403  public function reallyDoQuery( $limit, $offset = false ) {
404  $fname = static::class . '::reallyDoQuery';
405  $dbr = $this->getRecacheDB();
406  $query = $this->getQueryInfo();
407  $order = $this->getOrderFields();
408 
409  if ( $this->sortDescending() ) {
410  foreach ( $order as &$field ) {
411  $field .= ' DESC';
412  }
413  }
414 
415  if ( is_array( $query ) ) {
416  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
417  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
418  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
419  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
420  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
421 
422  if ( $order ) {
423  $options['ORDER BY'] = $order;
424  }
425 
426  if ( $limit !== false ) {
427  $options['LIMIT'] = intval( $limit );
428  }
429 
430  if ( $offset !== false ) {
431  $options['OFFSET'] = intval( $offset );
432  }
433 
434  $res = $dbr->select( $tables, $fields, $conds, $fname,
435  $options, $join_conds
436  );
437  } else {
438  // Old-fashioned raw SQL style, deprecated
439  $sql = $this->getSQL();
440  $sql .= ' ORDER BY ' . implode( ', ', $order );
441  $sql = $dbr->limitResult( $sql, $limit, $offset );
442  $res = $dbr->query( $sql, $fname );
443  }
444 
445  return $res;
446  }
447 
454  public function doQuery( $offset = false, $limit = false ) {
455  if ( $this->isCached() && $this->isCacheable() ) {
456  return $this->fetchFromCache( $limit, $offset );
457  } else {
458  return $this->reallyDoQuery( $limit, $offset );
459  }
460  }
461 
469  public function fetchFromCache( $limit, $offset = false ) {
470  $dbr = wfGetDB( DB_REPLICA );
471  $options = [];
472 
473  if ( $limit !== false ) {
474  $options['LIMIT'] = intval( $limit );
475  }
476 
477  if ( $offset !== false ) {
478  $options['OFFSET'] = intval( $offset );
479  }
480 
481  $order = $this->getCacheOrderFields();
482  if ( $this->sortDescending() ) {
483  foreach ( $order as &$field ) {
484  $field .= " DESC";
485  }
486  }
487  if ( $order ) {
488  $options['ORDER BY'] = $order;
489  }
490 
491  return $dbr->select( 'querycache',
492  [ 'qc_type',
493  'namespace' => 'qc_namespace',
494  'title' => 'qc_title',
495  'value' => 'qc_value' ],
496  [ 'qc_type' => $this->getName() ],
497  __METHOD__,
498  $options
499  );
500  }
501 
508  function getCacheOrderFields() {
509  return [ 'value' ];
510  }
511 
515  public function getCachedTimestamp() {
516  if ( is_null( $this->cachedTimestamp ) ) {
517  $dbr = wfGetDB( DB_REPLICA );
518  $fname = static::class . '::getCachedTimestamp';
519  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
520  [ 'qci_type' => $this->getName() ], $fname );
521  }
522  return $this->cachedTimestamp;
523  }
524 
537  protected function getLimitOffset() {
538  list( $limit, $offset ) = $this->getRequest()->getLimitOffset();
539  if ( $this->getConfig()->get( 'MiserMode' ) ) {
540  $maxResults = $this->getMaxResults();
541  // Can't display more than max results on a page
542  $limit = min( $limit, $maxResults );
543  // Can't skip over more than the end of $maxResults
544  $offset = min( $offset, $maxResults + 1 );
545  }
546  return [ $limit, $offset ];
547  }
548 
557  protected function getDBLimit( $uiLimit, $uiOffset ) {
558  $maxResults = $this->getMaxResults();
559  if ( $this->getConfig()->get( 'MiserMode' ) ) {
560  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
561  return max( $limit, 0 );
562  } else {
563  return $uiLimit + 1;
564  }
565  }
566 
576  protected function getMaxResults() {
577  // Max of 10000, unless we store more than 10000 in query cache.
578  return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
579  }
580 
586  public function execute( $par ) {
587  $user = $this->getUser();
588  if ( !$this->userCanExecute( $user ) ) {
589  $this->displayRestrictionError();
590  return;
591  }
592 
593  $this->setHeaders();
594  $this->outputHeader();
595 
596  $out = $this->getOutput();
597 
598  if ( $this->isCached() && !$this->isCacheable() ) {
599  $out->addWikiMsg( 'querypage-disabled' );
600  return;
601  }
602 
603  $out->setSyndicated( $this->isSyndicated() );
604 
605  if ( $this->limit == 0 && $this->offset == 0 ) {
606  list( $this->limit, $this->offset ) = $this->getLimitOffset();
607  }
608  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
609  // @todo Use doQuery()
610  if ( !$this->isCached() ) {
611  # select one extra row for navigation
612  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
613  } else {
614  # Get the cached result, select one extra row for navigation
615  $res = $this->fetchFromCache( $dbLimit, $this->offset );
616  if ( !$this->listoutput ) {
617  # Fetch the timestamp of this update
618  $ts = $this->getCachedTimestamp();
619  $lang = $this->getLanguage();
620  $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
621 
622  if ( $ts ) {
623  $updated = $lang->userTimeAndDate( $ts, $user );
624  $updateddate = $lang->userDate( $ts, $user );
625  $updatedtime = $lang->userTime( $ts, $user );
626  $out->addMeta( 'Data-Cache-Time', $ts );
627  $out->addJsConfigVars( 'dataCacheTime', $ts );
628  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
629  } else {
630  $out->addWikiMsg( 'perfcached', $maxResults );
631  }
632 
633  # If updates on this page have been disabled, let the user know
634  # that the data set won't be refreshed for now
635  if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
636  && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
637  ) {
638  $out->wrapWikiMsg(
639  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
640  'querypage-no-updates'
641  );
642  }
643  }
644  }
645 
646  $this->numRows = $res->numRows();
647 
648  $dbr = $this->getRecacheDB();
649  $this->preprocessResults( $dbr, $res );
650 
651  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
652 
653  # Top header and navigation
654  if ( $this->shownavigation ) {
655  $out->addHTML( $this->getPageHeader() );
656  if ( $this->numRows > 0 ) {
657  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
658  min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
659  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
660  # Disable the "next" link when we reach the end
661  $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
662  && ( $this->offset + $this->limit >= $this->getMaxResults() );
663  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
664  $paging = $this->buildPrevNextNavigation( $this->offset,
665  $this->limit, $this->linkParameters(), $atEnd, $par );
666  $out->addHTML( '<p>' . $paging . '</p>' );
667  } else {
668  # No results to show, so don't bother with "showing X of Y" etc.
669  # -- just let the user know and give up now
670  $this->showEmptyText();
671  $out->addHTML( Xml::closeElement( 'div' ) );
672  return;
673  }
674  }
675 
676  # The actual results; specialist subclasses will want to handle this
677  # with more than a straight list, so we hand them the info, plus
678  # an OutputPage, and let them get on with it
679  $this->outputResults( $out,
680  $this->getSkin(),
681  $dbr, # Should use IResultWrapper for this
682  $res,
683  min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
684  $this->offset );
685 
686  # Repeat the paging links at the bottom
687  if ( $this->shownavigation ) {
688  $out->addHTML( '<p>' . $paging . '</p>' );
689  }
690 
691  $out->addHTML( Xml::closeElement( 'div' ) );
692  }
693 
705  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
706  if ( $num > 0 ) {
707  $html = [];
708  if ( !$this->listoutput ) {
709  $html[] = $this->openList( $offset );
710  }
711 
712  # $res might contain the whole 1,000 rows, so we read up to
713  # $num [should update this to use a Pager]
714  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
715  $line = $this->formatResult( $skin, $row );
716  if ( $line ) {
717  $html[] = $this->listoutput
718  ? $line
719  : "<li>{$line}</li>\n";
720  }
721  }
722 
723  if ( !$this->listoutput ) {
724  $html[] = $this->closeList();
725  }
726 
727  $html = $this->listoutput
728  ? MediaWikiServices::getInstance()->getContentLanguage()->listToText( $html )
729  : implode( '', $html );
730 
731  $out->addHTML( $html );
732  }
733  }
734 
739  function openList( $offset ) {
740  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
741  }
742 
746  function closeList() {
747  return "</ol>\n";
748  }
749 
755  function preprocessResults( $db, $res ) {
756  }
757 
768  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
769  if ( !$res->numRows() ) {
770  return;
771  }
772 
773  $batch = new LinkBatch;
774  foreach ( $res as $row ) {
775  $batch->add( $ns ?? $row->namespace, $row->title );
776  }
777  $batch->execute();
778 
779  $res->seek( 0 );
780  }
781 }
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:586
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:1972
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
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' 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:1529
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: QueryPage.php:705
bool $shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:63
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:2147
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:454
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:179
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:576
$value
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:234
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:469
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:960
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. '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=(\*-\*)") 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. '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:1970
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:274
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
Definition: QueryPage.php:537
$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:36
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:767
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:739
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:375
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:285
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:755
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:403
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:156
$res
Definition: database.txt:21
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:557
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:202
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:1972
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:41
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:263
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:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
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:1972
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:131
int $numRows
The number of rows returned by the query.
Definition: QueryPage.php:53
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:508
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:126
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:38
getConfig()
Shortcut to get main config object.
int $limit
Definition: QueryPage.php:44
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:193
getCachedTimestamp()
Definition: QueryPage.php:515
const DB_REPLICA
Definition: defines.php:25
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:768
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:166
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don&#39;t let it run in miser mode...
Definition: QueryPage.php:213
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:224
delete( $table, $conds, $fname=__METHOD__)
DELETE query wrapper.
string null $cachedTimestamp
Definition: QueryPage.php:58
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:297
Database error base class.
Definition: DBError.php:30
isSyndicated()
Sometime we don&#39;t want to build rss / atom feeds.
Definition: QueryPage.php:243
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates...
Definition: QueryPage.php:74
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1454
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1623
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200