MediaWiki  master
QueryPage.php
Go to the documentation of this file.
1 <?php
36 
46 abstract class QueryPage extends SpecialPage {
48  protected $listoutput = false;
49 
51  protected $offset = 0;
52 
54  protected $limit = 0;
55 
63  protected $numRows;
64 
68  protected $cachedTimestamp = null;
69 
73  protected $shownavigation = true;
74 
76  private $loadBalancer = null;
77 
79  private $linkBatchFactory = null;
80 
91  public static function getPages() {
92  static $qp = null;
93 
94  if ( $qp === null ) {
95  $qp = [
96  [ SpecialAncientPages::class, 'Ancientpages' ],
97  [ SpecialBrokenRedirects::class, 'BrokenRedirects' ],
98  [ SpecialDeadendPages::class, 'Deadendpages' ],
99  [ SpecialDoubleRedirects::class, 'DoubleRedirects' ],
100  [ SpecialListDuplicatedFiles::class, 'ListDuplicatedFiles' ],
101  [ SpecialLinkSearch::class, 'LinkSearch' ],
102  [ SpecialListRedirects::class, 'Listredirects' ],
103  [ SpecialLonelyPages::class, 'Lonelypages' ],
104  [ SpecialLongPages::class, 'Longpages' ],
105  [ SpecialMediaStatistics::class, 'MediaStatistics', SpecialMediaStatistics::MAX_LIMIT ],
106  [ SpecialMIMESearch::class, 'MIMEsearch' ],
107  [ SpecialMostCategories::class, 'Mostcategories' ],
108  [ SpecialMostImages::class, 'Mostimages' ],
109  [ SpecialMostInterwikis::class, 'Mostinterwikis' ],
110  [ SpecialMostLinkedCategories::class, 'Mostlinkedcategories' ],
111  [ SpecialMostLinkedTemplates::class, 'Mostlinkedtemplates' ],
112  [ SpecialMostLinked::class, 'Mostlinked' ],
113  [ SpecialMostRevisions::class, 'Mostrevisions' ],
114  [ SpecialFewestRevisions::class, 'Fewestrevisions' ],
115  [ SpecialShortPages::class, 'Shortpages' ],
116  [ SpecialUncategorizedCategories::class, 'Uncategorizedcategories' ],
117  [ SpecialUncategorizedPages::class, 'Uncategorizedpages' ],
118  [ SpecialUncategorizedImages::class, 'Uncategorizedimages' ],
119  [ SpecialUncategorizedTemplates::class, 'Uncategorizedtemplates' ],
120  [ SpecialUnusedCategories::class, 'Unusedcategories' ],
121  [ SpecialUnusedImages::class, 'Unusedimages' ],
122  [ SpecialWantedCategories::class, 'Wantedcategories' ],
123  [ SpecialWantedFiles::class, 'Wantedfiles' ],
124  [ SpecialWantedPages::class, 'Wantedpages' ],
125  [ SpecialWantedTemplates::class, 'Wantedtemplates' ],
126  [ SpecialUnwatchedPages::class, 'Unwatchedpages' ],
127  [ SpecialUnusedTemplates::class, 'Unusedtemplates' ],
128  [ SpecialWithoutInterwiki::class, 'Withoutinterwiki' ],
129  ];
130  Hooks::runner()->onWgQueryPages( $qp );
131  }
132 
133  return $qp;
134  }
135 
140  final protected function setLinkBatchFactory( LinkBatchFactory $linkBatchFactory ) {
141  $this->linkBatchFactory = $linkBatchFactory;
142  }
143 
148  final protected function getLinkBatchFactory(): LinkBatchFactory {
149  if ( $this->linkBatchFactory === null ) {
150  // Fallback if not provided
151  // TODO Change to wfWarn in a future release
152  $this->linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
153  }
154  return $this->linkBatchFactory;
155  }
156 
162  public static function getDisabledQueryPages( Config $config ) {
163  $disableQueryPageUpdate = $config->get( MainConfigNames::DisableQueryPageUpdate );
164 
165  if ( !is_array( $disableQueryPageUpdate ) ) {
166  return [];
167  }
168 
169  $pages = [];
170  foreach ( $disableQueryPageUpdate as $name => $runMode ) {
171  if ( is_int( $name ) ) {
172  // The run mode may be omitted
173  $pages[$runMode] = 'disabled';
174  } else {
175  $pages[$name] = $runMode;
176  }
177  }
178  return $pages;
179  }
180 
186  protected function setListoutput( $bool ) {
187  $this->listoutput = $bool;
188  }
189 
217  public function getQueryInfo() {
218  // @phan-suppress-next-line PhanTypeMismatchReturnProbablyReal null needed for b/c checks
219  return null;
220  }
221 
229  protected function getSQL() {
230  wfDeprecated( __METHOD__, '1.39' );
231  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
232  . "getQuery() properly" );
233  }
234 
243  protected function getOrderFields() {
244  return [ 'value' ];
245  }
246 
258  public function usesTimestamps() {
259  return false;
260  }
261 
268  protected function sortDescending() {
269  return true;
270  }
271 
292  public function isExpensive() {
293  return $this->getConfig()->get( MainConfigNames::DisableQueryPages );
294  }
295 
304  public function isCacheable() {
305  return true;
306  }
307 
315  public function isCached() {
316  return $this->isExpensive() && $this->getConfig()->get( MainConfigNames::MiserMode );
317  }
318 
325  public function isSyndicated() {
326  return true;
327  }
328 
338  abstract protected function formatResult( $skin, $result );
339 
346  protected function getPageHeader() {
347  return '';
348  }
349 
357  protected function showEmptyText() {
358  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
359  }
360 
369  protected function linkParameters() {
370  return [];
371  }
372 
383  public function recache( $limit, $ignoreErrors = true ) {
384  if ( !$this->isCacheable() ) {
385  return 0;
386  }
387 
388  $fname = static::class . '::recache';
389  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
390 
391  try {
392  // Do query
393  $res = $this->reallyDoQuery( $limit, false );
394  $num = false;
395  if ( $res ) {
396  $num = $res->numRows();
397  // Fetch results
398  $vals = [];
399  foreach ( $res as $i => $row ) {
400  if ( isset( $row->value ) ) {
401  if ( $this->usesTimestamps() ) {
402  $value = (int)wfTimestamp( TS_UNIX, $row->value );
403  } else {
404  $value = intval( $row->value ); // T16414
405  }
406  } else {
407  $value = $i;
408  }
409 
410  $vals[] = [
411  'qc_type' => $this->getName(),
412  'qc_namespace' => $row->namespace,
413  'qc_title' => $row->title,
414  'qc_value' => $value
415  ];
416  }
417 
418  $dbw->doAtomicSection(
419  $fname,
420  function ( IDatabase $dbw, $fname ) use ( $vals ) {
421  // Clear out any old cached data
422  $dbw->delete( 'querycache',
423  [ 'qc_type' => $this->getName() ],
424  $fname
425  );
426  // Save results into the querycache table on the primary DB
427  if ( count( $vals ) ) {
428  $dbw->insert( 'querycache', $vals, $fname );
429  }
430  // Update the querycache_info record for the page
431  $dbw->upsert(
432  'querycache_info',
433  [
434  'qci_type' => $this->getName(),
435  'qci_timestamp' => $dbw->timestamp(),
436  ],
437  'qci_type',
438  [
439  'qci_timestamp' => $dbw->timestamp(),
440  ],
441  $fname
442  );
443  }
444  );
445  }
446  } catch ( DBError $e ) {
447  if ( !$ignoreErrors ) {
448  throw $e; // report query error
449  }
450  $num = false; // set result to false to indicate error
451  }
452 
453  return $num;
454  }
455 
461  protected function getRecacheDB() {
462  return $this->getDBLoadBalancer()
463  ->getConnectionRef( ILoadBalancer::DB_REPLICA, 'vslow' );
464  }
465 
472  public function delete( LinkTarget $title ) {
473  if ( $this->isCached() ) {
474  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
475  $dbw->delete( 'querycache', [
476  'qc_type' => $this->getName(),
477  'qc_namespace' => $title->getNamespace(),
478  'qc_title' => $title->getDBkey(),
479  ], __METHOD__ );
480  }
481  }
482 
488  public function deleteAllCachedData() {
489  $fname = static::class . '::' . __FUNCTION__;
490  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
491  $dbw->delete( 'querycache',
492  [ 'qc_type' => $this->getName() ],
493  $fname
494  );
495  $dbw->delete( 'querycachetwo',
496  [ 'qcc_type' => $this->getName() ],
497  $fname
498  );
499  $dbw->delete( 'querycache_info',
500  [ 'qci_type' => $this->getName() ],
501  $fname
502  );
503  }
504 
513  public function reallyDoQuery( $limit, $offset = false ) {
514  $fname = static::class . '::reallyDoQuery';
515  $dbr = $this->getRecacheDB();
516  $query = $this->getQueryInfo();
517  $order = $this->getOrderFields();
518 
519  if ( $this->sortDescending() ) {
520  foreach ( $order as &$field ) {
521  $field .= ' DESC';
522  }
523  }
524 
525  if ( is_array( $query ) ) {
526  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
527  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
528  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
529  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
530  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
531 
532  if ( $order ) {
533  $options['ORDER BY'] = $order;
534  }
535 
536  if ( $limit !== false ) {
537  $options['LIMIT'] = intval( $limit );
538  }
539 
540  if ( $offset !== false ) {
541  $options['OFFSET'] = intval( $offset );
542  }
543 
544  $res = $dbr->select( $tables, $fields, $conds, $fname,
545  $options, $join_conds
546  );
547  } else {
548  // Old-fashioned raw SQL style, deprecated
550  $this,
551  __CLASS__,
552  'getSQL',
553  '1.39'
554  );
555  $sql = $this->getSQL();
556  $sql .= ' ORDER BY ' . implode( ', ', $order );
557  $sql = $dbr->limitResult( $sql, $limit, $offset );
558  $res = $dbr->query( $sql, $fname );
559  }
560 
561  return $res;
562  }
563 
570  public function doQuery( $offset = false, $limit = false ) {
571  if ( $this->isCached() && $this->isCacheable() ) {
572  return $this->fetchFromCache( $limit, $offset );
573  } else {
574  return $this->reallyDoQuery( $limit, $offset );
575  }
576  }
577 
587  public function fetchFromCache( $limit, $offset = false ) {
588  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
589  $options = [];
590 
591  if ( $limit !== false ) {
592  $options['LIMIT'] = intval( $limit );
593  }
594 
595  if ( $offset !== false ) {
596  $options['OFFSET'] = intval( $offset );
597  }
598 
599  $order = $this->getCacheOrderFields();
600  if ( $this->sortDescending() ) {
601  foreach ( $order as &$field ) {
602  $field .= " DESC";
603  }
604  }
605  if ( $order ) {
606  $options['ORDER BY'] = $order;
607  }
608 
609  return $dbr->select( 'querycache',
610  [ 'qc_type',
611  'namespace' => 'qc_namespace',
612  'title' => 'qc_title',
613  'value' => 'qc_value' ],
614  [ 'qc_type' => $this->getName() ],
615  __METHOD__,
616  $options
617  );
618  }
619 
627  protected function getCacheOrderFields() {
628  return [ 'value' ];
629  }
630 
634  public function getCachedTimestamp() {
635  if ( $this->cachedTimestamp === null ) {
636  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
637  $fname = static::class . '::getCachedTimestamp';
638  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
639  [ 'qci_type' => $this->getName() ], $fname );
640  }
641  return $this->cachedTimestamp;
642  }
643 
656  protected function getLimitOffset() {
657  [ $limit, $offset ] = $this->getRequest()
658  ->getLimitOffsetForUser( $this->getUser() );
659  if ( $this->getConfig()->get( MainConfigNames::MiserMode ) ) {
660  $maxResults = $this->getMaxResults();
661  // Can't display more than max results on a page
662  $limit = min( $limit, $maxResults );
663  // Can't skip over more than the end of $maxResults
664  $offset = min( $offset, $maxResults + 1 );
665  }
666  return [ $limit, $offset ];
667  }
668 
677  protected function getDBLimit( $uiLimit, $uiOffset ) {
678  $maxResults = $this->getMaxResults();
679  if ( $this->getConfig()->get( MainConfigNames::MiserMode ) ) {
680  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
681  return max( $limit, 0 );
682  } else {
683  return $uiLimit + 1;
684  }
685  }
686 
697  protected function getMaxResults() {
698  // Max of 10000, unless we store more than 10000 in query cache.
699  return max( $this->getConfig()->get( MainConfigNames::QueryCacheLimit ), 10000 );
700  }
701 
708  public function execute( $par ) {
709  $this->checkPermissions();
710 
711  $this->setHeaders();
712  $this->outputHeader();
713 
714  $out = $this->getOutput();
715 
716  if ( $this->isCached() && !$this->isCacheable() ) {
717  $out->addWikiMsg( 'querypage-disabled' );
718  return;
719  }
720 
721  $out->setSyndicated( $this->isSyndicated() );
722 
723  if ( $this->limit == 0 && $this->offset == 0 ) {
724  [ $this->limit, $this->offset ] = $this->getLimitOffset();
725  }
726  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
727  // @todo Use doQuery()
728  if ( !$this->isCached() ) {
729  // select one extra row for navigation
730  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
731  } else {
732  // Get the cached result, select one extra row for navigation
733  $res = $this->fetchFromCache( $dbLimit, $this->offset );
734  if ( !$this->listoutput ) {
735  // Fetch the timestamp of this update
736  $ts = $this->getCachedTimestamp();
737  $lang = $this->getLanguage();
738  $maxResults = $lang->formatNum( $this->getConfig()->get(
739  MainConfigNames::QueryCacheLimit ) );
740 
741  if ( $ts ) {
742  $user = $this->getUser();
743  $updated = $lang->userTimeAndDate( $ts, $user );
744  $updateddate = $lang->userDate( $ts, $user );
745  $updatedtime = $lang->userTime( $ts, $user );
746  $out->addMeta( 'Data-Cache-Time', $ts );
747  $out->addJsConfigVars( 'dataCacheTime', $ts );
748  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
749  } else {
750  $out->addWikiMsg( 'perfcached', $maxResults );
751  }
752 
753  // If updates on this page have been disabled, let the user know
754  // that the data set won't be refreshed for now
755  $disabledQueryPages = self::getDisabledQueryPages( $this->getConfig() );
756  if ( isset( $disabledQueryPages[$this->getName()] ) ) {
757  $runMode = $disabledQueryPages[$this->getName()];
758  if ( $runMode === 'disabled' ) {
759  $out->wrapWikiMsg(
760  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
761  'querypage-no-updates'
762  );
763  } else {
764  // Messages used here: querypage-updates-periodical
765  $out->wrapWikiMsg(
766  "<div class=\"mw-querypage-updates-" . $runMode . "\">\n$1\n</div>",
767  'querypage-updates-' . $runMode
768  );
769  }
770  }
771  }
772  }
773 
774  $this->numRows = $res->numRows();
775 
776  $dbr = $this->getRecacheDB();
777  $this->preprocessResults( $dbr, $res );
778 
779  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
780 
781  // Top header and navigation
782  if ( $this->shownavigation ) {
783  $out->addHTML( $this->getPageHeader() );
784  if ( $this->numRows > 0 ) {
785  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
786  min( $this->numRows, $this->limit ), // do not show the one extra row, if exist
787  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
788  // Disable the "next" link when we reach the end
789  $miserMaxResults = $this->getConfig()->get( MainConfigNames::MiserMode )
790  && ( $this->offset + $this->limit >= $this->getMaxResults() );
791  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
792  $paging = $this->buildPrevNextNavigation( $this->offset,
793  $this->limit, $this->linkParameters(), $atEnd, $par );
794  $out->addHTML( '<p>' . $paging . '</p>' );
795  } else {
796  // No results to show, so don't bother with "showing X of Y" etc.
797  // -- just let the user know and give up now
798  $this->showEmptyText();
799  $out->addHTML( Xml::closeElement( 'div' ) );
800  return;
801  }
802  }
803 
804  // The actual results; specialist subclasses will want to handle this
805  // with more than a straight list, so we hand them the info, plus
806  // an OutputPage, and let them get on with it
807  $this->outputResults( $out,
808  $this->getSkin(),
809  $dbr, // Should use IResultWrapper for this
810  $res,
811  min( $this->numRows, $this->limit ), // do not format the one extra row, if exist
812  $this->offset );
813 
814  // Repeat the paging links at the bottom
815  if ( $this->shownavigation ) {
816  // @phan-suppress-next-line PhanPossiblyUndeclaredVariable paging is set when used here
817  $out->addHTML( '<p>' . $paging . '</p>' );
818  }
819 
820  $out->addHTML( Xml::closeElement( 'div' ) );
821  }
822 
836  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
837  if ( $num > 0 ) {
838  $html = [];
839  if ( !$this->listoutput ) {
840  $html[] = $this->openList( $offset );
841  }
842 
843  // $res might contain the whole 1,000 rows, so we read up to
844  // $num [should update this to use a Pager]
845  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
846  $line = $this->formatResult( $skin, $row );
847  if ( $line ) {
848  $html[] = $this->listoutput
849  ? $line
850  : "<li>{$line}</li>\n";
851  }
852  }
853 
854  if ( !$this->listoutput ) {
855  $html[] = $this->closeList();
856  }
857 
858  $html = $this->listoutput
859  ? $this->getContentLanguage()->listToText( $html )
860  : implode( '', $html );
861 
862  $out->addHTML( $html );
863  }
864  }
865 
870  protected function openList( $offset ) {
871  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
872  }
873 
877  protected function closeList() {
878  return "</ol>\n";
879  }
880 
887  protected function preprocessResults( $db, $res ) {
888  }
889 
902  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
903  if ( !$res->numRows() ) {
904  return;
905  }
906 
907  $batch = $this->getLinkBatchFactory()->newLinkBatch();
908  foreach ( $res as $row ) {
909  $batch->add( $ns ?? (int)$row->namespace, $row->title );
910  }
911  $batch->execute();
912 
913  $res->seek( 0 );
914  }
915 
920  final protected function setDBLoadBalancer( ILoadBalancer $loadBalancer ) {
921  $this->loadBalancer = $loadBalancer;
922  }
923 
928  final protected function getDBLoadBalancer(): ILoadBalancer {
929  if ( $this->loadBalancer === null ) {
930  // Fallback if not provided
931  // TODO Change to wfWarn in a future release
932  $this->loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
933  }
934  return $this->loadBalancer;
935  }
936 }
getUser()
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined('MW_SETUP_CALLBACK'))
Definition: WebStart.php:88
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:170
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:259
MediaWiki exception.
Definition: MWException.php:32
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.
Implements Special:Ancientpages.
A special page that lists most used images.
Querypage that lists the most wanted files.
A special page that lists most linked pages that does not exist.
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:46
isExpensive()
Should this query page only be updated offline on large wikis?
Definition: QueryPage.php:292
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
Definition: QueryPage.php:369
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:697
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:570
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:902
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:186
static getDisabledQueryPages(Config $config)
Get a list of disabled query pages and their run mode.
Definition: QueryPage.php:162
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:383
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:920
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:587
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:51
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: QueryPage.php:836
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:315
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:268
deleteAllCachedData()
Remove all cached value This is needed when the page is no longer using the cache.
Definition: QueryPage.php:488
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:325
getCachedTimestamp()
Definition: QueryPage.php:634
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
Definition: QueryPage.php:91
bool $shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:73
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:513
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:304
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:243
getLinkBatchFactory()
Definition: QueryPage.php:148
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:357
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
Definition: QueryPage.php:258
int $limit
Definition: QueryPage.php:54
getCacheOrderFields()
Return the order fields for fetchFromCache.
Definition: QueryPage.php:627
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:217
openList( $offset)
Definition: QueryPage.php:870
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:677
int $numRows
The number of rows returned by the query.
Definition: QueryPage.php:63
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:887
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:140
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:229
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:346
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition: QueryPage.php:48
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:708
string null false $cachedTimestamp
Definition: QueryPage.php:68
getDBLoadBalancer()
Definition: QueryPage.php:928
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffsetForUser().
Definition: QueryPage.php:656
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:461
Parent class for all special pages.
Definition: SpecialPage.php:45
Database error base class.
Definition: DBError.php:31
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:122
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:113
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:36
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.
This class is a delegate to ILBFactory for a given database cluster.
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...
const DB_REPLICA
Definition: defines.php:26
const DB_PRIMARY
Definition: defines.php:28
if(!isset( $args[0])) $lang