MediaWiki  master
QueryPage.php
Go to the documentation of this file.
1 <?php
31 
41 abstract class QueryPage extends SpecialPage {
43  protected $listoutput = false;
44 
46  protected $offset = 0;
47 
49  protected $limit = 0;
50 
58  protected $numRows;
59 
63  protected $cachedTimestamp = null;
64 
68  protected $shownavigation = true;
69 
71  private $loadBalancer = null;
72 
74  private $linkBatchFactory = null;
75 
85  public static function getPages() {
86  static $qp = null;
87 
88  if ( $qp === null ) {
89  // QueryPage subclass, Special page name
90  $qp = [
91  [ SpecialAncientPages::class, 'Ancientpages' ],
92  [ SpecialBrokenRedirects::class, 'BrokenRedirects' ],
93  [ SpecialDeadendPages::class, 'Deadendpages' ],
94  [ SpecialDoubleRedirects::class, 'DoubleRedirects' ],
95  [ SpecialFileDuplicateSearch::class, 'FileDuplicateSearch' ],
96  [ SpecialListDuplicatedFiles::class, 'ListDuplicatedFiles' ],
97  [ SpecialLinkSearch::class, 'LinkSearch' ],
98  [ SpecialListRedirects::class, 'Listredirects' ],
99  [ SpecialLonelyPages::class, 'Lonelypages' ],
100  [ SpecialLongPages::class, 'Longpages' ],
101  [ SpecialMediaStatistics::class, 'MediaStatistics' ],
102  [ SpecialMIMESearch::class, 'MIMEsearch' ],
103  [ SpecialMostCategories::class, 'Mostcategories' ],
104  [ MostimagesPage::class, 'Mostimages' ],
105  [ SpecialMostInterwikis::class, 'Mostinterwikis' ],
106  [ SpecialMostLinkedCategories::class, 'Mostlinkedcategories' ],
107  [ SpecialMostLinkedTemplates::class, 'Mostlinkedtemplates' ],
108  [ SpecialMostLinked::class, 'Mostlinked' ],
109  [ SpecialMostRevisions::class, 'Mostrevisions' ],
110  [ SpecialFewestRevisions::class, 'Fewestrevisions' ],
111  [ SpecialShortPages::class, 'Shortpages' ],
112  [ SpecialUncategorizedCategories::class, 'Uncategorizedcategories' ],
113  [ SpecialUncategorizedPages::class, 'Uncategorizedpages' ],
114  [ SpecialUncategorizedImages::class, 'Uncategorizedimages' ],
115  [ SpecialUncategorizedTemplates::class, 'Uncategorizedtemplates' ],
116  [ SpecialUnusedCategories::class, 'Unusedcategories' ],
117  [ SpecialUnusedImages::class, 'Unusedimages' ],
118  [ SpecialWantedCategories::class, 'Wantedcategories' ],
119  [ WantedFilesPage::class, 'Wantedfiles' ],
120  [ WantedPagesPage::class, 'Wantedpages' ],
121  [ SpecialWantedTemplates::class, 'Wantedtemplates' ],
122  [ SpecialUnwatchedPages::class, 'Unwatchedpages' ],
123  [ SpecialUnusedTemplates::class, 'Unusedtemplates' ],
124  [ SpecialWithoutInterwiki::class, 'Withoutinterwiki' ],
125  ];
126  Hooks::runner()->onWgQueryPages( $qp );
127  }
128 
129  return $qp;
130  }
131 
137  $this->linkBatchFactory = $linkBatchFactory;
138  }
139 
144  final protected function getLinkBatchFactory(): LinkBatchFactory {
145  if ( $this->linkBatchFactory === null ) {
146  // Fallback if not provided
147  // TODO Change to wfWarn in a future release
148  $this->linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
149  }
151  }
152 
158  public static function getDisabledQueryPages( Config $config ) {
159  $disableQueryPageUpdate = $config->get( 'DisableQueryPageUpdate' );
160 
161  if ( !is_array( $disableQueryPageUpdate ) ) {
162  return [];
163  }
164 
165  $pages = [];
166  foreach ( $disableQueryPageUpdate as $name => $runMode ) {
167  if ( is_int( $name ) ) {
168  // The run mode may be omitted
169  $pages[$runMode] = 'disabled';
170  } else {
171  $pages[$name] = $runMode;
172  }
173  }
174  return $pages;
175  }
176 
182  protected function setListoutput( $bool ) {
183  $this->listoutput = $bool;
184  }
185 
213  public function getQueryInfo() {
214  return null;
215  }
216 
223  protected function getSQL() {
224  /* Implement getQueryInfo() instead */
225  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
226  . "getQuery() properly" );
227  }
228 
237  protected function getOrderFields() {
238  return [ 'value' ];
239  }
240 
252  public function usesTimestamps() {
253  return false;
254  }
255 
262  protected function sortDescending() {
263  return true;
264  }
265 
274  public function isExpensive() {
275  return $this->getConfig()->get( 'DisableQueryPages' );
276  }
277 
286  public function isCacheable() {
287  return true;
288  }
289 
297  public function isCached() {
298  return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
299  }
300 
307  public function isSyndicated() {
308  return true;
309  }
310 
320  abstract protected function formatResult( $skin, $result );
321 
328  protected function getPageHeader() {
329  return '';
330  }
331 
339  protected function showEmptyText() {
340  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
341  }
342 
351  protected function linkParameters() {
352  return [];
353  }
354 
365  public function recache( $limit, $ignoreErrors = true ) {
366  if ( !$this->isCacheable() ) {
367  return 0;
368  }
369 
370  $fname = static::class . '::recache';
371  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_MASTER );
372  if ( !$dbw ) {
373  return false;
374  }
375 
376  try {
377  # Do query
378  $res = $this->reallyDoQuery( $limit, false );
379  $num = false;
380  if ( $res ) {
381  $num = $res->numRows();
382  # Fetch results
383  $vals = [];
384  foreach ( $res as $i => $row ) {
385  if ( isset( $row->value ) ) {
386  if ( $this->usesTimestamps() ) {
387  $value = wfTimestamp( TS_UNIX,
388  $row->value );
389  } else {
390  $value = intval( $row->value ); // T16414
391  }
392  } else {
393  $value = $i;
394  }
395 
396  $vals[] = [
397  'qc_type' => $this->getName(),
398  'qc_namespace' => $row->namespace,
399  'qc_title' => $row->title,
400  'qc_value' => $value
401  ];
402  }
403 
404  $dbw->doAtomicSection(
405  __METHOD__,
406  function ( IDatabase $dbw, $fname ) use ( $vals ) {
407  # Clear out any old cached data
408  $dbw->delete( 'querycache',
409  [ 'qc_type' => $this->getName() ],
410  $fname
411  );
412  # Save results into the querycache table on the master
413  if ( count( $vals ) ) {
414  $dbw->insert( 'querycache', $vals, $fname );
415  }
416  # Update the querycache_info record for the page
417  $dbw->delete( 'querycache_info',
418  [ 'qci_type' => $this->getName() ],
419  $fname
420  );
421  $dbw->insert( 'querycache_info',
422  [ 'qci_type' => $this->getName(),
423  'qci_timestamp' => $dbw->timestamp() ],
424  $fname
425  );
426  }
427  );
428  }
429  } catch ( DBError $e ) {
430  if ( !$ignoreErrors ) {
431  throw $e; // report query error
432  }
433  $num = false; // set result to false to indicate error
434  }
435 
436  return $num;
437  }
438 
444  protected function getRecacheDB() {
445  return $this->getDBLoadBalancer()
446  ->getConnectionRef( ILoadBalancer::DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
447  }
448 
455  public function delete( LinkTarget $title ) {
456  if ( $this->isCached() ) {
457  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_MASTER );
458  $dbw->delete( 'querycache', [
459  'qc_type' => $this->getName(),
460  'qc_namespace' => $title->getNamespace(),
461  'qc_title' => $title->getDBkey(),
462  ], __METHOD__ );
463  }
464  }
465 
474  public function reallyDoQuery( $limit, $offset = false ) {
475  $fname = static::class . '::reallyDoQuery';
476  $dbr = $this->getRecacheDB();
477  $query = $this->getQueryInfo();
478  $order = $this->getOrderFields();
479 
480  if ( $this->sortDescending() ) {
481  foreach ( $order as &$field ) {
482  $field .= ' DESC';
483  }
484  }
485 
486  if ( is_array( $query ) ) {
487  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
488  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
489  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
490  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
491  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
492 
493  if ( $order ) {
494  $options['ORDER BY'] = $order;
495  }
496 
497  if ( $limit !== false ) {
498  $options['LIMIT'] = intval( $limit );
499  }
500 
501  if ( $offset !== false ) {
502  $options['OFFSET'] = intval( $offset );
503  }
504 
505  $res = $dbr->select( $tables, $fields, $conds, $fname,
506  $options, $join_conds
507  );
508  } else {
509  // Old-fashioned raw SQL style, deprecated
510  $sql = $this->getSQL();
511  $sql .= ' ORDER BY ' . implode( ', ', $order );
512  $sql = $dbr->limitResult( $sql, $limit, $offset );
513  $res = $dbr->query( $sql, $fname );
514  }
515 
516  return $res;
517  }
518 
525  public function doQuery( $offset = false, $limit = false ) {
526  if ( $this->isCached() && $this->isCacheable() ) {
527  return $this->fetchFromCache( $limit, $offset );
528  } else {
529  return $this->reallyDoQuery( $limit, $offset );
530  }
531  }
532 
542  public function fetchFromCache( $limit, $offset = false ) {
543  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
544  $options = [];
545 
546  if ( $limit !== false ) {
547  $options['LIMIT'] = intval( $limit );
548  }
549 
550  if ( $offset !== false ) {
551  $options['OFFSET'] = intval( $offset );
552  }
553 
554  $order = $this->getCacheOrderFields();
555  if ( $this->sortDescending() ) {
556  foreach ( $order as &$field ) {
557  $field .= " DESC";
558  }
559  }
560  if ( $order ) {
561  $options['ORDER BY'] = $order;
562  }
563 
564  return $dbr->select( 'querycache',
565  [ 'qc_type',
566  'namespace' => 'qc_namespace',
567  'title' => 'qc_title',
568  'value' => 'qc_value' ],
569  [ 'qc_type' => $this->getName() ],
570  __METHOD__,
571  $options
572  );
573  }
574 
582  protected function getCacheOrderFields() {
583  return [ 'value' ];
584  }
585 
589  public function getCachedTimestamp() {
590  if ( $this->cachedTimestamp === null ) {
591  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
592  $fname = static::class . '::getCachedTimestamp';
593  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
594  [ 'qci_type' => $this->getName() ], $fname );
595  }
596  return $this->cachedTimestamp;
597  }
598 
611  protected function getLimitOffset() {
612  list( $limit, $offset ) = $this->getRequest()
613  ->getLimitOffsetForUser( $this->getUser() );
614  if ( $this->getConfig()->get( 'MiserMode' ) ) {
615  $maxResults = $this->getMaxResults();
616  // Can't display more than max results on a page
617  $limit = min( $limit, $maxResults );
618  // Can't skip over more than the end of $maxResults
619  $offset = min( $offset, $maxResults + 1 );
620  }
621  return [ $limit, $offset ];
622  }
623 
632  protected function getDBLimit( $uiLimit, $uiOffset ) {
633  $maxResults = $this->getMaxResults();
634  if ( $this->getConfig()->get( 'MiserMode' ) ) {
635  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
636  return max( $limit, 0 );
637  } else {
638  return $uiLimit + 1;
639  }
640  }
641 
652  protected function getMaxResults() {
653  // Max of 10000, unless we store more than 10000 in query cache.
654  return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
655  }
656 
663  public function execute( $par ) {
664  $this->checkPermissions();
665 
666  $this->setHeaders();
667  $this->outputHeader();
668 
669  $out = $this->getOutput();
670 
671  if ( $this->isCached() && !$this->isCacheable() ) {
672  $out->addWikiMsg( 'querypage-disabled' );
673  return;
674  }
675 
676  $out->setSyndicated( $this->isSyndicated() );
677 
678  if ( $this->limit == 0 && $this->offset == 0 ) {
679  list( $this->limit, $this->offset ) = $this->getLimitOffset();
680  }
681  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
682  // @todo Use doQuery()
683  if ( !$this->isCached() ) {
684  # select one extra row for navigation
685  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
686  } else {
687  # Get the cached result, select one extra row for navigation
688  $res = $this->fetchFromCache( $dbLimit, $this->offset );
689  if ( !$this->listoutput ) {
690  # Fetch the timestamp of this update
691  $ts = $this->getCachedTimestamp();
692  $lang = $this->getLanguage();
693  $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
694 
695  if ( $ts ) {
696  $user = $this->getUser();
697  $updated = $lang->userTimeAndDate( $ts, $user );
698  $updateddate = $lang->userDate( $ts, $user );
699  $updatedtime = $lang->userTime( $ts, $user );
700  $out->addMeta( 'Data-Cache-Time', $ts );
701  $out->addJsConfigVars( 'dataCacheTime', $ts );
702  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
703  } else {
704  $out->addWikiMsg( 'perfcached', $maxResults );
705  }
706 
707  # If updates on this page have been disabled, let the user know
708  # that the data set won't be refreshed for now
709  $disabledQueryPages = self::getDisabledQueryPages( $this->getConfig() );
710  if ( isset( $disabledQueryPages[$this->getName()] ) ) {
711  $runMode = $disabledQueryPages[$this->getName()];
712  if ( $runMode === 'disabled' ) {
713  $out->wrapWikiMsg(
714  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
715  'querypage-no-updates'
716  );
717  } else {
718  // Messages used here: querypage-updates-periodical
719  $out->wrapWikiMsg(
720  "<div class=\"mw-querypage-updates-" . $runMode . "\">\n$1\n</div>",
721  'querypage-updates-' . $runMode
722  );
723  }
724  }
725  }
726  }
727 
728  $this->numRows = $res->numRows();
729 
730  $dbr = $this->getRecacheDB();
731  $this->preprocessResults( $dbr, $res );
732 
733  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
734 
735  # Top header and navigation
736  if ( $this->shownavigation ) {
737  $out->addHTML( $this->getPageHeader() );
738  if ( $this->numRows > 0 ) {
739  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
740  min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
741  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
742  # Disable the "next" link when we reach the end
743  $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
744  && ( $this->offset + $this->limit >= $this->getMaxResults() );
745  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
746  $paging = $this->buildPrevNextNavigation( $this->offset,
747  $this->limit, $this->linkParameters(), $atEnd, $par );
748  $out->addHTML( '<p>' . $paging . '</p>' );
749  } else {
750  # No results to show, so don't bother with "showing X of Y" etc.
751  # -- just let the user know and give up now
752  $this->showEmptyText();
753  $out->addHTML( Xml::closeElement( 'div' ) );
754  return;
755  }
756  }
757 
758  # The actual results; specialist subclasses will want to handle this
759  # with more than a straight list, so we hand them the info, plus
760  # an OutputPage, and let them get on with it
761  $this->outputResults( $out,
762  $this->getSkin(),
763  $dbr, # Should use IResultWrapper for this
764  $res,
765  min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
766  $this->offset );
767 
768  # Repeat the paging links at the bottom
769  if ( $this->shownavigation ) {
770  $out->addHTML( '<p>' . $paging . '</p>' );
771  }
772 
773  $out->addHTML( Xml::closeElement( 'div' ) );
774  }
775 
789  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
790  if ( $num > 0 ) {
791  $html = [];
792  if ( !$this->listoutput ) {
793  $html[] = $this->openList( $offset );
794  }
795 
796  # $res might contain the whole 1,000 rows, so we read up to
797  # $num [should update this to use a Pager]
798  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
799  $line = $this->formatResult( $skin, $row );
800  if ( $line ) {
801  $html[] = $this->listoutput
802  ? $line
803  : "<li>{$line}</li>\n";
804  }
805  }
806 
807  if ( !$this->listoutput ) {
808  $html[] = $this->closeList();
809  }
810 
811  $html = $this->listoutput
812  ? $this->getContentLanguage()->listToText( $html )
813  : implode( '', $html );
814 
815  $out->addHTML( $html );
816  }
817  }
818 
823  protected function openList( $offset ) {
824  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
825  }
826 
830  protected function closeList() {
831  return "</ol>\n";
832  }
833 
840  protected function preprocessResults( $db, $res ) {
841  }
842 
855  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
856  if ( !$res->numRows() ) {
857  return;
858  }
859 
860  $batch = $this->getLinkBatchFactory()->newLinkBatch();
861  foreach ( $res as $row ) {
862  $batch->add( $ns ?? $row->namespace, $row->title );
863  }
864  $batch->execute();
865 
866  $res->seek( 0 );
867  }
868 
873  final protected function setDBLoadBalancer( ILoadBalancer $loadBalancer ) {
874  $this->loadBalancer = $loadBalancer;
875  }
876 
881  final protected function getDBLoadBalancer(): ILoadBalancer {
882  if ( $this->loadBalancer === null ) {
883  // Fallback if not provided
884  // TODO Change to wfWarn in a future release
885  $this->loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
886  }
887  return $this->loadBalancer;
888  }
889 }
QueryPage\setListoutput
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:182
QueryPage\$listoutput
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition: QueryPage.php:43
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:911
QueryPage\getDBLoadBalancer
getDBLoadBalancer()
Definition: QueryPage.php:881
QueryPage\getCacheOrderFields
getCacheOrderFields()
Return the order fields for fetchFromCache.
Definition: QueryPage.php:582
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:789
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:173
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
QueryPage\isCacheable
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:286
QueryPage\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:328
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1832
QueryPage\linkParameters
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
Definition: QueryPage.php:351
QueryPage\formatResult
formatResult( $skin, $result)
Formats the results of the query for display.
QueryPage\outputResults
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: QueryPage.php:789
SpecialPage\checkPermissions
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
Definition: SpecialPage.php:357
QueryPage\getLimitOffset
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffsetForUser().
Definition: QueryPage.php:611
QueryPage\openList
openList( $offset)
Definition: QueryPage.php:823
QueryPage\preprocessResults
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:840
QueryPage\execute
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:663
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:819
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:829
$res
$res
Definition: testCompression.php:57
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:179
Wikimedia\Rdbms\DBError
Database error base class @newable.
Definition: DBError.php:32
QueryPage\reallyDoQuery
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:474
QueryPage
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition: QueryPage.php:41
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:110
QueryPage\executeLBFromResultWrapper
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:855
QueryPage\$offset
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:46
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
$dbr
$dbr
Definition: testCompression.php:54
QueryPage\$limit
int $limit
Definition: QueryPage.php:49
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:136
QueryPage\getCachedTimestamp
getCachedTimestamp()
Definition: QueryPage.php:589
QueryPage\closeList
closeList()
Definition: QueryPage.php:830
Config
Interface for configuration instances.
Definition: Config.php:30
Wikimedia\Rdbms\IDatabase\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
MWException
MediaWiki exception.
Definition: MWException.php:29
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:877
QueryPage\getMaxResults
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:652
QueryPage\$cachedTimestamp
string null $cachedTimestamp
Definition: QueryPage.php:63
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
Config\get
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
QueryPage\isCached
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:297
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:38
QueryPage\$shownavigation
bool $shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:68
QueryPage\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: QueryPage.php:274
QueryPage\recache
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:365
$title
$title
Definition: testCompression.php:38
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:617
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:799
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
DB_MASTER
const DB_MASTER
Definition: defines.php:26
QueryPage\getRecacheDB
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:444
QueryPage\$numRows
int $numRows
The number of rows returned by the query.
Definition: QueryPage.php:58
QueryPage\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:213
QueryPage\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:237
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:43
Hooks\runner
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:172
QueryPage\doQuery
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:525
$line
$line
Definition: mcc.php:119
SpecialPage\buildPrevNextNavigation
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
Definition: SpecialPage.php:1054
QueryPage\fetchFromCache
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:542
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:779
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:873
QueryPage\showEmptyText
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:339
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
Wikimedia\Rdbms\IDatabase\insert
insert( $table, $rows, $fname=__METHOD__, $options=[])
Insert the given row(s) into a table.
QueryPage\getDisabledQueryPages
static getDisabledQueryPages(Config $config)
Get a list of query pages disabled and with it's run mode.
Definition: QueryPage.php:158
QueryPage\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: QueryPage.php:307
QueryPage\getSQL
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:223
QueryPage\getLinkBatchFactory
getLinkBatchFactory()
Definition: QueryPage.php:144
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:119
QueryPage\usesTimestamps
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
Definition: QueryPage.php:252
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
QueryPage\getDBLimit
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:632
SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
Definition: SpecialPage.php:839
QueryPage\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:262
QueryPage\getPages
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
Definition: QueryPage.php:85
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:708
Wikimedia\Rdbms\IDatabase\delete
delete( $table, $conds, $fname=__METHOD__)
Delete all rows in a table that match a condition.
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81