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  [ SpecialListDuplicatedFiles::class, 'ListDuplicatedFiles' ],
96  [ SpecialLinkSearch::class, 'LinkSearch' ],
97  [ SpecialListRedirects::class, 'Listredirects' ],
98  [ SpecialLonelyPages::class, 'Lonelypages' ],
99  [ SpecialLongPages::class, 'Longpages' ],
100  [ SpecialMediaStatistics::class, 'MediaStatistics' ],
101  [ SpecialMIMESearch::class, 'MIMEsearch' ],
102  [ SpecialMostCategories::class, 'Mostcategories' ],
103  [ MostimagesPage::class, 'Mostimages' ],
104  [ SpecialMostInterwikis::class, 'Mostinterwikis' ],
105  [ SpecialMostLinkedCategories::class, 'Mostlinkedcategories' ],
106  [ SpecialMostLinkedTemplates::class, 'Mostlinkedtemplates' ],
107  [ SpecialMostLinked::class, 'Mostlinked' ],
108  [ SpecialMostRevisions::class, 'Mostrevisions' ],
109  [ SpecialFewestRevisions::class, 'Fewestrevisions' ],
110  [ SpecialShortPages::class, 'Shortpages' ],
111  [ SpecialUncategorizedCategories::class, 'Uncategorizedcategories' ],
112  [ SpecialUncategorizedPages::class, 'Uncategorizedpages' ],
113  [ SpecialUncategorizedImages::class, 'Uncategorizedimages' ],
114  [ SpecialUncategorizedTemplates::class, 'Uncategorizedtemplates' ],
115  [ SpecialUnusedCategories::class, 'Unusedcategories' ],
116  [ SpecialUnusedImages::class, 'Unusedimages' ],
117  [ SpecialWantedCategories::class, 'Wantedcategories' ],
118  [ WantedFilesPage::class, 'Wantedfiles' ],
119  [ WantedPagesPage::class, 'Wantedpages' ],
120  [ SpecialWantedTemplates::class, 'Wantedtemplates' ],
121  [ SpecialUnwatchedPages::class, 'Unwatchedpages' ],
122  [ SpecialUnusedTemplates::class, 'Unusedtemplates' ],
123  [ SpecialWithoutInterwiki::class, 'Withoutinterwiki' ],
124  ];
125  Hooks::runner()->onWgQueryPages( $qp );
126  }
127 
128  return $qp;
129  }
130 
136  $this->linkBatchFactory = $linkBatchFactory;
137  }
138 
143  final protected function getLinkBatchFactory(): LinkBatchFactory {
144  if ( $this->linkBatchFactory === null ) {
145  // Fallback if not provided
146  // TODO Change to wfWarn in a future release
147  $this->linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
148  }
150  }
151 
157  public static function getDisabledQueryPages( Config $config ) {
158  $disableQueryPageUpdate = $config->get( 'DisableQueryPageUpdate' );
159 
160  if ( !is_array( $disableQueryPageUpdate ) ) {
161  return [];
162  }
163 
164  $pages = [];
165  foreach ( $disableQueryPageUpdate as $name => $runMode ) {
166  if ( is_int( $name ) ) {
167  // The run mode may be omitted
168  $pages[$runMode] = 'disabled';
169  } else {
170  $pages[$name] = $runMode;
171  }
172  }
173  return $pages;
174  }
175 
181  protected function setListoutput( $bool ) {
182  $this->listoutput = $bool;
183  }
184 
212  public function getQueryInfo() {
213  return null;
214  }
215 
222  protected function getSQL() {
223  /* Implement getQueryInfo() instead */
224  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
225  . "getQuery() properly" );
226  }
227 
236  protected function getOrderFields() {
237  return [ 'value' ];
238  }
239 
251  public function usesTimestamps() {
252  return false;
253  }
254 
261  protected function sortDescending() {
262  return true;
263  }
264 
273  public function isExpensive() {
274  return $this->getConfig()->get( 'DisableQueryPages' );
275  }
276 
285  public function isCacheable() {
286  return true;
287  }
288 
296  public function isCached() {
297  return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
298  }
299 
306  public function isSyndicated() {
307  return true;
308  }
309 
319  abstract protected function formatResult( $skin, $result );
320 
327  protected function getPageHeader() {
328  return '';
329  }
330 
338  protected function showEmptyText() {
339  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
340  }
341 
350  protected function linkParameters() {
351  return [];
352  }
353 
364  public function recache( $limit, $ignoreErrors = true ) {
365  if ( !$this->isCacheable() ) {
366  return 0;
367  }
368 
369  $fname = static::class . '::recache';
370  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
371 
372  try {
373  // Do query
374  $res = $this->reallyDoQuery( $limit, false );
375  $num = false;
376  if ( $res ) {
377  $num = $res->numRows();
378  // Fetch results
379  $vals = [];
380  foreach ( $res as $i => $row ) {
381  if ( isset( $row->value ) ) {
382  if ( $this->usesTimestamps() ) {
383  $value = wfTimestamp( TS_UNIX,
384  $row->value );
385  } else {
386  $value = intval( $row->value ); // T16414
387  }
388  } else {
389  $value = $i;
390  }
391 
392  $vals[] = [
393  'qc_type' => $this->getName(),
394  'qc_namespace' => $row->namespace,
395  'qc_title' => $row->title,
396  'qc_value' => $value
397  ];
398  }
399 
400  $dbw->doAtomicSection(
401  __METHOD__,
402  function ( IDatabase $dbw, $fname ) use ( $vals ) {
403  // Clear out any old cached data
404  $dbw->delete( 'querycache',
405  [ 'qc_type' => $this->getName() ],
406  $fname
407  );
408  // Save results into the querycache table on the master
409  if ( count( $vals ) ) {
410  $dbw->insert( 'querycache', $vals, $fname );
411  }
412  // Update the querycache_info record for the page
413  $dbw->delete( 'querycache_info',
414  [ 'qci_type' => $this->getName() ],
415  $fname
416  );
417  $dbw->insert( 'querycache_info',
418  [ 'qci_type' => $this->getName(),
419  'qci_timestamp' => $dbw->timestamp() ],
420  $fname
421  );
422  }
423  );
424  }
425  } catch ( DBError $e ) {
426  if ( !$ignoreErrors ) {
427  throw $e; // report query error
428  }
429  $num = false; // set result to false to indicate error
430  }
431 
432  return $num;
433  }
434 
440  protected function getRecacheDB() {
441  return $this->getDBLoadBalancer()
442  ->getConnectionRef( ILoadBalancer::DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
443  }
444 
451  public function delete( LinkTarget $title ) {
452  if ( $this->isCached() ) {
453  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
454  $dbw->delete( 'querycache', [
455  'qc_type' => $this->getName(),
456  'qc_namespace' => $title->getNamespace(),
457  'qc_title' => $title->getDBkey(),
458  ], __METHOD__ );
459  }
460  }
461 
467  public function deleteAllCachedData() {
468  $fname = static::class . '::' . __FUNCTION__;
469  $dbw = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_PRIMARY );
470  $dbw->delete( 'querycache',
471  [ 'qc_type' => $this->getName() ],
472  $fname
473  );
474  $dbw->delete( 'querycachetwo',
475  [ 'qcc_type' => $this->getName() ],
476  $fname
477  );
478  $dbw->delete( 'querycache_info',
479  [ 'qci_type' => $this->getName() ],
480  $fname
481  );
482  }
483 
492  public function reallyDoQuery( $limit, $offset = false ) {
493  $fname = static::class . '::reallyDoQuery';
494  $dbr = $this->getRecacheDB();
495  $query = $this->getQueryInfo();
496  $order = $this->getOrderFields();
497 
498  if ( $this->sortDescending() ) {
499  foreach ( $order as &$field ) {
500  $field .= ' DESC';
501  }
502  }
503 
504  if ( is_array( $query ) ) {
505  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
506  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
507  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
508  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
509  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
510 
511  if ( $order ) {
512  $options['ORDER BY'] = $order;
513  }
514 
515  if ( $limit !== false ) {
516  $options['LIMIT'] = intval( $limit );
517  }
518 
519  if ( $offset !== false ) {
520  $options['OFFSET'] = intval( $offset );
521  }
522 
523  $res = $dbr->select( $tables, $fields, $conds, $fname,
524  $options, $join_conds
525  );
526  } else {
527  // Old-fashioned raw SQL style, deprecated
528  $sql = $this->getSQL();
529  $sql .= ' ORDER BY ' . implode( ', ', $order );
530  $sql = $dbr->limitResult( $sql, $limit, $offset );
531  $res = $dbr->query( $sql, $fname );
532  }
533 
534  return $res;
535  }
536 
543  public function doQuery( $offset = false, $limit = false ) {
544  if ( $this->isCached() && $this->isCacheable() ) {
545  return $this->fetchFromCache( $limit, $offset );
546  } else {
547  return $this->reallyDoQuery( $limit, $offset );
548  }
549  }
550 
560  public function fetchFromCache( $limit, $offset = false ) {
561  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
562  $options = [];
563 
564  if ( $limit !== false ) {
565  $options['LIMIT'] = intval( $limit );
566  }
567 
568  if ( $offset !== false ) {
569  $options['OFFSET'] = intval( $offset );
570  }
571 
572  $order = $this->getCacheOrderFields();
573  if ( $this->sortDescending() ) {
574  foreach ( $order as &$field ) {
575  $field .= " DESC";
576  }
577  }
578  if ( $order ) {
579  $options['ORDER BY'] = $order;
580  }
581 
582  return $dbr->select( 'querycache',
583  [ 'qc_type',
584  'namespace' => 'qc_namespace',
585  'title' => 'qc_title',
586  'value' => 'qc_value' ],
587  [ 'qc_type' => $this->getName() ],
588  __METHOD__,
589  $options
590  );
591  }
592 
600  protected function getCacheOrderFields() {
601  return [ 'value' ];
602  }
603 
607  public function getCachedTimestamp() {
608  if ( $this->cachedTimestamp === null ) {
609  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
610  $fname = static::class . '::getCachedTimestamp';
611  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
612  [ 'qci_type' => $this->getName() ], $fname );
613  }
614  return $this->cachedTimestamp;
615  }
616 
629  protected function getLimitOffset() {
630  list( $limit, $offset ) = $this->getRequest()
631  ->getLimitOffsetForUser( $this->getUser() );
632  if ( $this->getConfig()->get( 'MiserMode' ) ) {
633  $maxResults = $this->getMaxResults();
634  // Can't display more than max results on a page
635  $limit = min( $limit, $maxResults );
636  // Can't skip over more than the end of $maxResults
637  $offset = min( $offset, $maxResults + 1 );
638  }
639  return [ $limit, $offset ];
640  }
641 
650  protected function getDBLimit( $uiLimit, $uiOffset ) {
651  $maxResults = $this->getMaxResults();
652  if ( $this->getConfig()->get( 'MiserMode' ) ) {
653  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
654  return max( $limit, 0 );
655  } else {
656  return $uiLimit + 1;
657  }
658  }
659 
670  protected function getMaxResults() {
671  // Max of 10000, unless we store more than 10000 in query cache.
672  return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
673  }
674 
681  public function execute( $par ) {
682  $this->checkPermissions();
683 
684  $this->setHeaders();
685  $this->outputHeader();
686 
687  $out = $this->getOutput();
688 
689  if ( $this->isCached() && !$this->isCacheable() ) {
690  $out->addWikiMsg( 'querypage-disabled' );
691  return;
692  }
693 
694  $out->setSyndicated( $this->isSyndicated() );
695 
696  if ( $this->limit == 0 && $this->offset == 0 ) {
697  list( $this->limit, $this->offset ) = $this->getLimitOffset();
698  }
699  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
700  // @todo Use doQuery()
701  if ( !$this->isCached() ) {
702  // select one extra row for navigation
703  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
704  } else {
705  // Get the cached result, select one extra row for navigation
706  $res = $this->fetchFromCache( $dbLimit, $this->offset );
707  if ( !$this->listoutput ) {
708  // Fetch the timestamp of this update
709  $ts = $this->getCachedTimestamp();
710  $lang = $this->getLanguage();
711  $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
712 
713  if ( $ts ) {
714  $user = $this->getUser();
715  $updated = $lang->userTimeAndDate( $ts, $user );
716  $updateddate = $lang->userDate( $ts, $user );
717  $updatedtime = $lang->userTime( $ts, $user );
718  $out->addMeta( 'Data-Cache-Time', $ts );
719  $out->addJsConfigVars( 'dataCacheTime', $ts );
720  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
721  } else {
722  $out->addWikiMsg( 'perfcached', $maxResults );
723  }
724 
725  // If updates on this page have been disabled, let the user know
726  // that the data set won't be refreshed for now
727  $disabledQueryPages = self::getDisabledQueryPages( $this->getConfig() );
728  if ( isset( $disabledQueryPages[$this->getName()] ) ) {
729  $runMode = $disabledQueryPages[$this->getName()];
730  if ( $runMode === 'disabled' ) {
731  $out->wrapWikiMsg(
732  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
733  'querypage-no-updates'
734  );
735  } else {
736  // Messages used here: querypage-updates-periodical
737  $out->wrapWikiMsg(
738  "<div class=\"mw-querypage-updates-" . $runMode . "\">\n$1\n</div>",
739  'querypage-updates-' . $runMode
740  );
741  }
742  }
743  }
744  }
745 
746  $this->numRows = $res->numRows();
747 
748  $dbr = $this->getRecacheDB();
749  $this->preprocessResults( $dbr, $res );
750 
751  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
752 
753  // Top header and navigation
754  if ( $this->shownavigation ) {
755  $out->addHTML( $this->getPageHeader() );
756  if ( $this->numRows > 0 ) {
757  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
758  min( $this->numRows, $this->limit ), // do not show the one extra row, if exist
759  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
760  // Disable the "next" link when we reach the end
761  $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
762  && ( $this->offset + $this->limit >= $this->getMaxResults() );
763  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
764  $paging = $this->buildPrevNextNavigation( $this->offset,
765  $this->limit, $this->linkParameters(), $atEnd, $par );
766  $out->addHTML( '<p>' . $paging . '</p>' );
767  } else {
768  // No results to show, so don't bother with "showing X of Y" etc.
769  // -- just let the user know and give up now
770  $this->showEmptyText();
771  $out->addHTML( Xml::closeElement( 'div' ) );
772  return;
773  }
774  }
775 
776  // The actual results; specialist subclasses will want to handle this
777  // with more than a straight list, so we hand them the info, plus
778  // an OutputPage, and let them get on with it
779  $this->outputResults( $out,
780  $this->getSkin(),
781  $dbr, // Should use IResultWrapper for this
782  $res,
783  min( $this->numRows, $this->limit ), // do not format the one extra row, if exist
784  $this->offset );
785 
786  // Repeat the paging links at the bottom
787  if ( $this->shownavigation ) {
788  $out->addHTML( '<p>' . $paging . '</p>' );
789  }
790 
791  $out->addHTML( Xml::closeElement( 'div' ) );
792  }
793 
807  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
808  if ( $num > 0 ) {
809  $html = [];
810  if ( !$this->listoutput ) {
811  $html[] = $this->openList( $offset );
812  }
813 
814  // $res might contain the whole 1,000 rows, so we read up to
815  // $num [should update this to use a Pager]
816  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
817  $line = $this->formatResult( $skin, $row );
818  if ( $line ) {
819  $html[] = $this->listoutput
820  ? $line
821  : "<li>{$line}</li>\n";
822  }
823  }
824 
825  if ( !$this->listoutput ) {
826  $html[] = $this->closeList();
827  }
828 
829  $html = $this->listoutput
830  ? $this->getContentLanguage()->listToText( $html )
831  : implode( '', $html );
832 
833  $out->addHTML( $html );
834  }
835  }
836 
841  protected function openList( $offset ) {
842  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
843  }
844 
848  protected function closeList() {
849  return "</ol>\n";
850  }
851 
858  protected function preprocessResults( $db, $res ) {
859  }
860 
873  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
874  if ( !$res->numRows() ) {
875  return;
876  }
877 
878  $batch = $this->getLinkBatchFactory()->newLinkBatch();
879  foreach ( $res as $row ) {
880  $batch->add( $ns ?? $row->namespace, $row->title );
881  }
882  $batch->execute();
883 
884  $res->seek( 0 );
885  }
886 
891  final protected function setDBLoadBalancer( ILoadBalancer $loadBalancer ) {
892  $this->loadBalancer = $loadBalancer;
893  }
894 
899  final protected function getDBLoadBalancer(): ILoadBalancer {
900  if ( $this->loadBalancer === null ) {
901  // Fallback if not provided
902  // TODO Change to wfWarn in a future release
903  $this->loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
904  }
905  return $this->loadBalancer;
906  }
907 }
QueryPage\setListoutput
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:181
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:899
QueryPage\getCacheOrderFields
getCacheOrderFields()
Return the order fields for fetchFromCache.
Definition: QueryPage.php:600
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:186
QueryPage\$cachedTimestamp
string null false $cachedTimestamp
Definition: QueryPage.php:63
$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:285
QueryPage\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:327
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1692
QueryPage\linkParameters
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
Definition: QueryPage.php:350
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:807
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:629
QueryPage\openList
openList( $offset)
Definition: QueryPage.php:841
QueryPage\preprocessResults
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:858
QueryPage\execute
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:681
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:492
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:873
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:135
QueryPage\getCachedTimestamp
getCachedTimestamp()
Definition: QueryPage.php:607
QueryPage\closeList
closeList()
Definition: QueryPage.php:848
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:670
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:296
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
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:273
QueryPage\recache
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:364
$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
QueryPage\getRecacheDB
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:440
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:212
QueryPage\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:236
QueryPage\deleteAllCachedData
deleteAllCachedData()
Remove all cached value This is needed when the page is no longer using the cache.
Definition: QueryPage.php:467
DB_PRIMARY
const DB_PRIMARY
Definition: defines.php:27
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:173
QueryPage\doQuery
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:543
$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:560
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:779
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:891
QueryPage\showEmptyText
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:338
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:157
QueryPage\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: QueryPage.php:306
QueryPage\getSQL
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:222
QueryPage\getLinkBatchFactory
getLinkBatchFactory()
Definition: QueryPage.php:143
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:251
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
QueryPage\getDBLimit
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:650
SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
Definition: SpecialPage.php:839
QueryPage\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:261
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