MediaWiki  master
QueryPage.php
Go to the documentation of this file.
1 <?php
32 
42 abstract class QueryPage extends SpecialPage {
44  protected $listoutput = false;
45 
47  protected $offset = 0;
48 
50  protected $limit = 0;
51 
59  protected $numRows;
60 
64  protected $cachedTimestamp = null;
65 
69  protected $shownavigation = true;
70 
72  private $loadBalancer = null;
73 
75  private $linkBatchFactory = null;
76 
87  public static function getPages() {
88  static $qp = null;
89 
90  if ( $qp === null ) {
91  $qp = [
92  [ SpecialAncientPages::class, 'Ancientpages' ],
93  [ SpecialBrokenRedirects::class, 'BrokenRedirects' ],
94  [ SpecialDeadendPages::class, 'Deadendpages' ],
95  [ SpecialDoubleRedirects::class, 'DoubleRedirects' ],
96  [ SpecialListDuplicatedFiles::class, 'ListDuplicatedFiles' ],
97  [ SpecialLinkSearch::class, 'LinkSearch' ],
98  [ SpecialListRedirects::class, 'Listredirects' ],
99  [ SpecialLonelyPages::class, 'Lonelypages' ],
100  [ SpecialLongPages::class, 'Longpages' ],
101  [ SpecialMediaStatistics::class, 'MediaStatistics', SpecialMediaStatistics::MAX_LIMIT ],
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( MainConfigNames::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  // @phan-suppress-next-line PhanTypeMismatchReturnProbablyReal null needed for b/c checks
215  return null;
216  }
217 
225  protected function getSQL() {
227  $this,
228  __CLASS__,
229  'getSQL',
230  '1.39'
231  );
232  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
233  . "getQuery() properly" );
234  }
235 
244  protected function getOrderFields() {
245  return [ 'value' ];
246  }
247 
259  public function usesTimestamps() {
260  return false;
261  }
262 
269  protected function sortDescending() {
270  return true;
271  }
272 
281  public function isExpensive() {
282  return $this->getConfig()->get( MainConfigNames::DisableQueryPages );
283  }
284 
293  public function isCacheable() {
294  return true;
295  }
296 
304  public function isCached() {
305  return $this->isExpensive() && $this->getConfig()->get( MainConfigNames::MiserMode );
306  }
307 
314  public function isSyndicated() {
315  return true;
316  }
317 
327  abstract protected function formatResult( $skin, $result );
328 
335  protected function getPageHeader() {
336  return '';
337  }
338 
346  protected function showEmptyText() {
347  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
348  }
349 
358  protected function linkParameters() {
359  return [];
360  }
361 
372  public function recache( $limit, $ignoreErrors = true ) {
373  if ( !$this->isCacheable() ) {
374  return 0;
375  }
376 
377  $fname = static::class . '::recache';
378  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
379 
380  try {
381  // Do query
382  $res = $this->reallyDoQuery( $limit, false );
383  $num = false;
384  if ( $res ) {
385  $num = $res->numRows();
386  // Fetch results
387  $vals = [];
388  foreach ( $res as $i => $row ) {
389  if ( isset( $row->value ) ) {
390  if ( $this->usesTimestamps() ) {
391  $value = (int)wfTimestamp( TS_UNIX, $row->value );
392  } else {
393  $value = intval( $row->value ); // T16414
394  }
395  } else {
396  $value = $i;
397  }
398 
399  $vals[] = [
400  'qc_type' => $this->getName(),
401  'qc_namespace' => $row->namespace,
402  'qc_title' => $row->title,
403  'qc_value' => $value
404  ];
405  }
406 
407  $dbw->doAtomicSection(
408  __METHOD__,
409  function ( IDatabase $dbw, $fname ) use ( $vals ) {
410  // Clear out any old cached data
411  $dbw->delete( 'querycache',
412  [ 'qc_type' => $this->getName() ],
413  $fname
414  );
415  // Save results into the querycache table on the primary DB
416  if ( count( $vals ) ) {
417  $dbw->insert( 'querycache', $vals, $fname );
418  }
419  // Update the querycache_info record for the page
420  $dbw->upsert(
421  'querycache_info',
422  [
423  'qci_type' => $this->getName(),
424  'qci_timestamp' => $dbw->timestamp(),
425  ],
426  'qci_type',
427  [
428  'qci_timestamp' => $dbw->timestamp(),
429  ],
430  $fname
431  );
432  }
433  );
434  }
435  } catch ( DBError $e ) {
436  if ( !$ignoreErrors ) {
437  throw $e; // report query error
438  }
439  $num = false; // set result to false to indicate error
440  }
441 
442  return $num;
443  }
444 
450  protected function getRecacheDB() {
451  return $this->getDBLoadBalancer()
452  ->getConnectionRef( ILoadBalancer::DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
453  }
454 
461  public function delete( LinkTarget $title ) {
462  if ( $this->isCached() ) {
463  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
464  $dbw->delete( 'querycache', [
465  'qc_type' => $this->getName(),
466  'qc_namespace' => $title->getNamespace(),
467  'qc_title' => $title->getDBkey(),
468  ], __METHOD__ );
469  }
470  }
471 
477  public function deleteAllCachedData() {
478  $fname = static::class . '::' . __FUNCTION__;
479  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
480  $dbw->delete( 'querycache',
481  [ 'qc_type' => $this->getName() ],
482  $fname
483  );
484  $dbw->delete( 'querycachetwo',
485  [ 'qcc_type' => $this->getName() ],
486  $fname
487  );
488  $dbw->delete( 'querycache_info',
489  [ 'qci_type' => $this->getName() ],
490  $fname
491  );
492  }
493 
502  public function reallyDoQuery( $limit, $offset = false ) {
503  $fname = static::class . '::reallyDoQuery';
504  $dbr = $this->getRecacheDB();
505  $query = $this->getQueryInfo();
506  $order = $this->getOrderFields();
507 
508  if ( $this->sortDescending() ) {
509  foreach ( $order as &$field ) {
510  $field .= ' DESC';
511  }
512  }
513 
514  if ( is_array( $query ) ) {
515  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
516  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
517  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
518  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
519  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
520 
521  if ( $order ) {
522  $options['ORDER BY'] = $order;
523  }
524 
525  if ( $limit !== false ) {
526  $options['LIMIT'] = intval( $limit );
527  }
528 
529  if ( $offset !== false ) {
530  $options['OFFSET'] = intval( $offset );
531  }
532 
533  $res = $dbr->select( $tables, $fields, $conds, $fname,
534  $options, $join_conds
535  );
536  } else {
537  // Old-fashioned raw SQL style, deprecated
538  $sql = $this->getSQL();
539  $sql .= ' ORDER BY ' . implode( ', ', $order );
540  $sql = $dbr->limitResult( $sql, $limit, $offset );
541  $res = $dbr->query( $sql, $fname );
542  }
543 
544  return $res;
545  }
546 
553  public function doQuery( $offset = false, $limit = false ) {
554  if ( $this->isCached() && $this->isCacheable() ) {
555  return $this->fetchFromCache( $limit, $offset );
556  } else {
557  return $this->reallyDoQuery( $limit, $offset );
558  }
559  }
560 
570  public function fetchFromCache( $limit, $offset = false ) {
571  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
572  $options = [];
573 
574  if ( $limit !== false ) {
575  $options['LIMIT'] = intval( $limit );
576  }
577 
578  if ( $offset !== false ) {
579  $options['OFFSET'] = intval( $offset );
580  }
581 
582  $order = $this->getCacheOrderFields();
583  if ( $this->sortDescending() ) {
584  foreach ( $order as &$field ) {
585  $field .= " DESC";
586  }
587  }
588  if ( $order ) {
589  $options['ORDER BY'] = $order;
590  }
591 
592  return $dbr->select( 'querycache',
593  [ 'qc_type',
594  'namespace' => 'qc_namespace',
595  'title' => 'qc_title',
596  'value' => 'qc_value' ],
597  [ 'qc_type' => $this->getName() ],
598  __METHOD__,
599  $options
600  );
601  }
602 
610  protected function getCacheOrderFields() {
611  return [ 'value' ];
612  }
613 
617  public function getCachedTimestamp() {
618  if ( $this->cachedTimestamp === null ) {
619  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
620  $fname = static::class . '::getCachedTimestamp';
621  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
622  [ 'qci_type' => $this->getName() ], $fname );
623  }
624  return $this->cachedTimestamp;
625  }
626 
639  protected function getLimitOffset() {
640  list( $limit, $offset ) = $this->getRequest()
641  ->getLimitOffsetForUser( $this->getUser() );
642  if ( $this->getConfig()->get( MainConfigNames::MiserMode ) ) {
643  $maxResults = $this->getMaxResults();
644  // Can't display more than max results on a page
645  $limit = min( $limit, $maxResults );
646  // Can't skip over more than the end of $maxResults
647  $offset = min( $offset, $maxResults + 1 );
648  }
649  return [ $limit, $offset ];
650  }
651 
660  protected function getDBLimit( $uiLimit, $uiOffset ) {
661  $maxResults = $this->getMaxResults();
662  if ( $this->getConfig()->get( MainConfigNames::MiserMode ) ) {
663  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
664  return max( $limit, 0 );
665  } else {
666  return $uiLimit + 1;
667  }
668  }
669 
680  protected function getMaxResults() {
681  // Max of 10000, unless we store more than 10000 in query cache.
682  return max( $this->getConfig()->get( MainConfigNames::QueryCacheLimit ), 10000 );
683  }
684 
691  public function execute( $par ) {
692  $this->checkPermissions();
693 
694  $this->setHeaders();
695  $this->outputHeader();
696 
697  $out = $this->getOutput();
698 
699  if ( $this->isCached() && !$this->isCacheable() ) {
700  $out->addWikiMsg( 'querypage-disabled' );
701  return;
702  }
703 
704  $out->setSyndicated( $this->isSyndicated() );
705 
706  if ( $this->limit == 0 && $this->offset == 0 ) {
707  list( $this->limit, $this->offset ) = $this->getLimitOffset();
708  }
709  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
710  // @todo Use doQuery()
711  if ( !$this->isCached() ) {
712  // select one extra row for navigation
713  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
714  } else {
715  // Get the cached result, select one extra row for navigation
716  $res = $this->fetchFromCache( $dbLimit, $this->offset );
717  if ( !$this->listoutput ) {
718  // Fetch the timestamp of this update
719  $ts = $this->getCachedTimestamp();
720  $lang = $this->getLanguage();
721  $maxResults = $lang->formatNum( $this->getConfig()->get(
722  MainConfigNames::QueryCacheLimit ) );
723 
724  if ( $ts ) {
725  $user = $this->getUser();
726  $updated = $lang->userTimeAndDate( $ts, $user );
727  $updateddate = $lang->userDate( $ts, $user );
728  $updatedtime = $lang->userTime( $ts, $user );
729  $out->addMeta( 'Data-Cache-Time', $ts );
730  $out->addJsConfigVars( 'dataCacheTime', $ts );
731  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
732  } else {
733  $out->addWikiMsg( 'perfcached', $maxResults );
734  }
735 
736  // If updates on this page have been disabled, let the user know
737  // that the data set won't be refreshed for now
738  $disabledQueryPages = self::getDisabledQueryPages( $this->getConfig() );
739  if ( isset( $disabledQueryPages[$this->getName()] ) ) {
740  $runMode = $disabledQueryPages[$this->getName()];
741  if ( $runMode === 'disabled' ) {
742  $out->wrapWikiMsg(
743  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
744  'querypage-no-updates'
745  );
746  } else {
747  // Messages used here: querypage-updates-periodical
748  $out->wrapWikiMsg(
749  "<div class=\"mw-querypage-updates-" . $runMode . "\">\n$1\n</div>",
750  'querypage-updates-' . $runMode
751  );
752  }
753  }
754  }
755  }
756 
757  $this->numRows = $res->numRows();
758 
759  $dbr = $this->getRecacheDB();
760  $this->preprocessResults( $dbr, $res );
761 
762  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
763 
764  // Top header and navigation
765  if ( $this->shownavigation ) {
766  $out->addHTML( $this->getPageHeader() );
767  if ( $this->numRows > 0 ) {
768  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
769  min( $this->numRows, $this->limit ), // do not show the one extra row, if exist
770  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
771  // Disable the "next" link when we reach the end
772  $miserMaxResults = $this->getConfig()->get( MainConfigNames::MiserMode )
773  && ( $this->offset + $this->limit >= $this->getMaxResults() );
774  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
775  $paging = $this->buildPrevNextNavigation( $this->offset,
776  $this->limit, $this->linkParameters(), $atEnd, $par );
777  $out->addHTML( '<p>' . $paging . '</p>' );
778  } else {
779  // No results to show, so don't bother with "showing X of Y" etc.
780  // -- just let the user know and give up now
781  $this->showEmptyText();
782  $out->addHTML( Xml::closeElement( 'div' ) );
783  return;
784  }
785  }
786 
787  // The actual results; specialist subclasses will want to handle this
788  // with more than a straight list, so we hand them the info, plus
789  // an OutputPage, and let them get on with it
790  $this->outputResults( $out,
791  $this->getSkin(),
792  $dbr, // Should use IResultWrapper for this
793  $res,
794  min( $this->numRows, $this->limit ), // do not format the one extra row, if exist
795  $this->offset );
796 
797  // Repeat the paging links at the bottom
798  if ( $this->shownavigation ) {
799  // @phan-suppress-next-line PhanPossiblyUndeclaredVariable paging is set when used here
800  $out->addHTML( '<p>' . $paging . '</p>' );
801  }
802 
803  $out->addHTML( Xml::closeElement( 'div' ) );
804  }
805 
819  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
820  if ( $num > 0 ) {
821  $html = [];
822  if ( !$this->listoutput ) {
823  $html[] = $this->openList( $offset );
824  }
825 
826  // $res might contain the whole 1,000 rows, so we read up to
827  // $num [should update this to use a Pager]
828  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
829  $line = $this->formatResult( $skin, $row );
830  if ( $line ) {
831  $html[] = $this->listoutput
832  ? $line
833  : "<li>{$line}</li>\n";
834  }
835  }
836 
837  if ( !$this->listoutput ) {
838  $html[] = $this->closeList();
839  }
840 
841  $html = $this->listoutput
842  ? $this->getContentLanguage()->listToText( $html )
843  : implode( '', $html );
844 
845  $out->addHTML( $html );
846  }
847  }
848 
853  protected function openList( $offset ) {
854  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
855  }
856 
860  protected function closeList() {
861  return "</ol>\n";
862  }
863 
870  protected function preprocessResults( $db, $res ) {
871  }
872 
885  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
886  if ( !$res->numRows() ) {
887  return;
888  }
889 
890  $batch = $this->getLinkBatchFactory()->newLinkBatch();
891  foreach ( $res as $row ) {
892  $batch->add( $ns ?? (int)$row->namespace, $row->title );
893  }
894  $batch->execute();
895 
896  $res->seek( 0 );
897  }
898 
903  final protected function setDBLoadBalancer( ILoadBalancer $loadBalancer ) {
904  $this->loadBalancer = $loadBalancer;
905  }
906 
911  final protected function getDBLoadBalancer(): ILoadBalancer {
912  if ( $this->loadBalancer === null ) {
913  // Fallback if not provided
914  // TODO Change to wfWarn in a future release
915  $this->loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
916  }
917  return $this->loadBalancer;
918  }
919 }
getUser()
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition: WebStart.php:82
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:173
static detectDeprecatedOverride( $instance, $class, $method, $version=false, $component=false, $callerOffset=2)
Show a warning if $method declared in $class is overridden in $instance.
Definition: MWDebug.php:258
MediaWiki exception.
Definition: MWException.php:29
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.
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:42
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: QueryPage.php:281
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
Definition: QueryPage.php:358
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:680
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:553
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:885
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:182
static getDisabledQueryPages(Config $config)
Get a list of query pages disabled and with it's run mode.
Definition: QueryPage.php:158
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:372
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:903
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:75
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:570
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:47
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: QueryPage.php:819
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:304
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:269
deleteAllCachedData()
Remove all cached value This is needed when the page is no longer using the cache.
Definition: QueryPage.php:477
formatResult( $skin, $result)
Formats the results of the query for display.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Definition: QueryPage.php:314
getCachedTimestamp()
Definition: QueryPage.php:617
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
Definition: QueryPage.php:87
bool $shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:69
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:502
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:293
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:244
getLinkBatchFactory()
Definition: QueryPage.php:144
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:346
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
Definition: QueryPage.php:259
int $limit
Definition: QueryPage.php:50
getCacheOrderFields()
Return the order fields for fetchFromCache.
Definition: QueryPage.php:610
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:213
openList( $offset)
Definition: QueryPage.php:853
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:660
int $numRows
The number of rows returned by the query.
Definition: QueryPage.php:59
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:870
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:136
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:225
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:335
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition: QueryPage.php:44
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:691
string null false $cachedTimestamp
Definition: QueryPage.php:64
getDBLoadBalancer()
Definition: QueryPage.php:911
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:72
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffsetForUser().
Definition: QueryPage.php:639
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:450
Parent class for all special pages.
Definition: SpecialPage.php:44
Database error base class.
Definition: DBError.php:32
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:121
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:112
Interface for configuration instances.
Definition: Config.php:30
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:39
delete( $table, $conds, $fname=__METHOD__)
Delete all rows in a table that match a condition.
upsert( $table, array $rows, $uniqueKeys, array $set, $fname=__METHOD__)
Upsert row(s) into a table, in the provided order, while updating conflicting rows.
insert( $table, $rows, $fname=__METHOD__, $options=[])
Insert row(s) into a table, in the provided order.
Database cluster connection, tracking, load balancing, and transaction manager interface.
Result wrapper for grabbing data queried from an IDatabase object.
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
$line
Definition: mcc.php:119
const DB_REPLICA
Definition: defines.php:26
const DB_PRIMARY
Definition: defines.php:28
if(!isset( $args[0])) $lang