MediaWiki  1.32.5
QueryPage.php
Go to the documentation of this file.
1 <?php
28 
35 abstract class QueryPage extends SpecialPage {
37  protected $listoutput = false;
38 
40  protected $offset = 0;
41 
43  protected $limit = 0;
44 
50  protected $numRows;
51 
52  protected $cachedTimestamp = null;
53 
57  protected $shownavigation = true;
58 
67  public static function getPages() {
68  static $qp = null;
69 
70  if ( $qp === null ) {
71  // QueryPage subclass, Special page name
72  $qp = [
73  [ AncientPagesPage::class, 'Ancientpages' ],
74  [ BrokenRedirectsPage::class, 'BrokenRedirects' ],
75  [ DeadendPagesPage::class, 'Deadendpages' ],
76  [ DoubleRedirectsPage::class, 'DoubleRedirects' ],
77  [ FileDuplicateSearchPage::class, 'FileDuplicateSearch' ],
78  [ ListDuplicatedFilesPage::class, 'ListDuplicatedFiles' ],
79  [ LinkSearchPage::class, 'LinkSearch' ],
80  [ ListredirectsPage::class, 'Listredirects' ],
81  [ LonelyPagesPage::class, 'Lonelypages' ],
82  [ LongPagesPage::class, 'Longpages' ],
83  [ MediaStatisticsPage::class, 'MediaStatistics' ],
84  [ MIMEsearchPage::class, 'MIMEsearch' ],
85  [ MostcategoriesPage::class, 'Mostcategories' ],
86  [ MostimagesPage::class, 'Mostimages' ],
87  [ MostinterwikisPage::class, 'Mostinterwikis' ],
88  [ MostlinkedCategoriesPage::class, 'Mostlinkedcategories' ],
89  [ MostlinkedTemplatesPage::class, 'Mostlinkedtemplates' ],
90  [ MostlinkedPage::class, 'Mostlinked' ],
91  [ MostrevisionsPage::class, 'Mostrevisions' ],
92  [ FewestrevisionsPage::class, 'Fewestrevisions' ],
93  [ ShortPagesPage::class, 'Shortpages' ],
94  [ UncategorizedCategoriesPage::class, 'Uncategorizedcategories' ],
95  [ UncategorizedPagesPage::class, 'Uncategorizedpages' ],
96  [ UncategorizedImagesPage::class, 'Uncategorizedimages' ],
97  [ UncategorizedTemplatesPage::class, 'Uncategorizedtemplates' ],
98  [ UnusedCategoriesPage::class, 'Unusedcategories' ],
99  [ UnusedimagesPage::class, 'Unusedimages' ],
100  [ WantedCategoriesPage::class, 'Wantedcategories' ],
101  [ WantedFilesPage::class, 'Wantedfiles' ],
102  [ WantedPagesPage::class, 'Wantedpages' ],
103  [ WantedTemplatesPage::class, 'Wantedtemplates' ],
104  [ UnwatchedpagesPage::class, 'Unwatchedpages' ],
105  [ UnusedtemplatesPage::class, 'Unusedtemplates' ],
106  [ WithoutInterwikiPage::class, 'Withoutinterwiki' ],
107  ];
108  Hooks::run( 'wgQueryPages', [ &$qp ] );
109  }
110 
111  return $qp;
112  }
113 
119  function setListoutput( $bool ) {
120  $this->listoutput = $bool;
121  }
122 
149  public function getQueryInfo() {
150  return null;
151  }
152 
159  function getSQL() {
160  /* Implement getQueryInfo() instead */
161  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
162  . "getQuery() properly" );
163  }
164 
172  function getOrderFields() {
173  return [ 'value' ];
174  }
175 
186  public function usesTimestamps() {
187  return false;
188  }
189 
195  function sortDescending() {
196  return true;
197  }
198 
206  public function isExpensive() {
207  return $this->getConfig()->get( 'DisableQueryPages' );
208  }
209 
217  public function isCacheable() {
218  return true;
219  }
220 
227  public function isCached() {
228  return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
229  }
230 
236  function isSyndicated() {
237  return true;
238  }
239 
249  abstract function formatResult( $skin, $result );
250 
256  function getPageHeader() {
257  return '';
258  }
259 
267  protected function showEmptyText() {
268  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
269  }
270 
278  function linkParameters() {
279  return [];
280  }
281 
293  function tryLastResult() {
294  return false;
295  }
296 
305  public function recache( $limit, $ignoreErrors = true ) {
306  if ( !$this->isCacheable() ) {
307  return 0;
308  }
309 
310  $fname = static::class . '::recache';
311  $dbw = wfGetDB( DB_MASTER );
312  if ( !$dbw ) {
313  return false;
314  }
315 
316  try {
317  # Do query
318  $res = $this->reallyDoQuery( $limit, false );
319  $num = false;
320  if ( $res ) {
321  $num = $res->numRows();
322  # Fetch results
323  $vals = [];
324  foreach ( $res as $row ) {
325  if ( isset( $row->value ) ) {
326  if ( $this->usesTimestamps() ) {
327  $value = wfTimestamp( TS_UNIX,
328  $row->value );
329  } else {
330  $value = intval( $row->value ); // T16414
331  }
332  } else {
333  $value = 0;
334  }
335 
336  $vals[] = [
337  'qc_type' => $this->getName(),
338  'qc_namespace' => $row->namespace,
339  'qc_title' => $row->title,
340  'qc_value' => $value
341  ];
342  }
343 
344  $dbw->doAtomicSection(
345  __METHOD__,
346  function ( IDatabase $dbw, $fname ) use ( $vals ) {
347  # Clear out any old cached data
348  $dbw->delete( 'querycache',
349  [ 'qc_type' => $this->getName() ],
350  $fname
351  );
352  # Save results into the querycache table on the master
353  if ( count( $vals ) ) {
354  $dbw->insert( 'querycache', $vals, $fname );
355  }
356  # Update the querycache_info record for the page
357  $dbw->delete( 'querycache_info',
358  [ 'qci_type' => $this->getName() ],
359  $fname
360  );
361  $dbw->insert( 'querycache_info',
362  [ 'qci_type' => $this->getName(),
363  'qci_timestamp' => $dbw->timestamp() ],
364  $fname
365  );
366  }
367  );
368  }
369  } catch ( DBError $e ) {
370  if ( !$ignoreErrors ) {
371  throw $e; // report query error
372  }
373  $num = false; // set result to false to indicate error
374  }
375 
376  return $num;
377  }
378 
383  function getRecacheDB() {
384  return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
385  }
386 
394  public function reallyDoQuery( $limit, $offset = false ) {
395  $fname = static::class . '::reallyDoQuery';
396  $dbr = $this->getRecacheDB();
397  $query = $this->getQueryInfo();
398  $order = $this->getOrderFields();
399 
400  if ( $this->sortDescending() ) {
401  foreach ( $order as &$field ) {
402  $field .= ' DESC';
403  }
404  }
405 
406  if ( is_array( $query ) ) {
407  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
408  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
409  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
410  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
411  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
412 
413  if ( $order ) {
414  $options['ORDER BY'] = $order;
415  }
416 
417  if ( $limit !== false ) {
418  $options['LIMIT'] = intval( $limit );
419  }
420 
421  if ( $offset !== false ) {
422  $options['OFFSET'] = intval( $offset );
423  }
424 
425  $res = $dbr->select( $tables, $fields, $conds, $fname,
426  $options, $join_conds
427  );
428  } else {
429  // Old-fashioned raw SQL style, deprecated
430  $sql = $this->getSQL();
431  $sql .= ' ORDER BY ' . implode( ', ', $order );
432  $sql = $dbr->limitResult( $sql, $limit, $offset );
433  $res = $dbr->query( $sql, $fname );
434  }
435 
436  return $res;
437  }
438 
445  public function doQuery( $offset = false, $limit = false ) {
446  if ( $this->isCached() && $this->isCacheable() ) {
447  return $this->fetchFromCache( $limit, $offset );
448  } else {
449  return $this->reallyDoQuery( $limit, $offset );
450  }
451  }
452 
460  public function fetchFromCache( $limit, $offset = false ) {
461  $dbr = wfGetDB( DB_REPLICA );
462  $options = [];
463 
464  if ( $limit !== false ) {
465  $options['LIMIT'] = intval( $limit );
466  }
467 
468  if ( $offset !== false ) {
469  $options['OFFSET'] = intval( $offset );
470  }
471 
472  $order = $this->getCacheOrderFields();
473  if ( $this->sortDescending() ) {
474  foreach ( $order as &$field ) {
475  $field .= " DESC";
476  }
477  }
478  if ( $order ) {
479  $options['ORDER BY'] = $order;
480  }
481 
482  return $dbr->select( 'querycache',
483  [ 'qc_type',
484  'namespace' => 'qc_namespace',
485  'title' => 'qc_title',
486  'value' => 'qc_value' ],
487  [ 'qc_type' => $this->getName() ],
488  __METHOD__,
489  $options
490  );
491  }
492 
499  function getCacheOrderFields() {
500  return [ 'value' ];
501  }
502 
503  public function getCachedTimestamp() {
504  if ( is_null( $this->cachedTimestamp ) ) {
505  $dbr = wfGetDB( DB_REPLICA );
506  $fname = static::class . '::getCachedTimestamp';
507  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
508  [ 'qci_type' => $this->getName() ], $fname );
509  }
510  return $this->cachedTimestamp;
511  }
512 
525  protected function getLimitOffset() {
526  list( $limit, $offset ) = $this->getRequest()->getLimitOffset();
527  if ( $this->getConfig()->get( 'MiserMode' ) ) {
528  $maxResults = $this->getMaxResults();
529  // Can't display more than max results on a page
530  $limit = min( $limit, $maxResults );
531  // Can't skip over more than the end of $maxResults
532  $offset = min( $offset, $maxResults + 1 );
533  }
534  return [ $limit, $offset ];
535  }
536 
545  protected function getDBLimit( $uiLimit, $uiOffset ) {
546  $maxResults = $this->getMaxResults();
547  if ( $this->getConfig()->get( 'MiserMode' ) ) {
548  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
549  return max( $limit, 0 );
550  } else {
551  return $uiLimit + 1;
552  }
553  }
554 
564  protected function getMaxResults() {
565  // Max of 10000, unless we store more than 10000 in query cache.
566  return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
567  }
568 
574  public function execute( $par ) {
575  $user = $this->getUser();
576  if ( !$this->userCanExecute( $user ) ) {
577  $this->displayRestrictionError();
578  return;
579  }
580 
581  $this->setHeaders();
582  $this->outputHeader();
583 
584  $out = $this->getOutput();
585 
586  if ( $this->isCached() && !$this->isCacheable() ) {
587  $out->addWikiMsg( 'querypage-disabled' );
588  return;
589  }
590 
591  $out->setSyndicated( $this->isSyndicated() );
592 
593  if ( $this->limit == 0 && $this->offset == 0 ) {
594  list( $this->limit, $this->offset ) = $this->getLimitOffset();
595  }
596  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
597  // @todo Use doQuery()
598  if ( !$this->isCached() ) {
599  # select one extra row for navigation
600  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
601  } else {
602  # Get the cached result, select one extra row for navigation
603  $res = $this->fetchFromCache( $dbLimit, $this->offset );
604  if ( !$this->listoutput ) {
605  # Fetch the timestamp of this update
606  $ts = $this->getCachedTimestamp();
607  $lang = $this->getLanguage();
608  $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
609 
610  if ( $ts ) {
611  $updated = $lang->userTimeAndDate( $ts, $user );
612  $updateddate = $lang->userDate( $ts, $user );
613  $updatedtime = $lang->userTime( $ts, $user );
614  $out->addMeta( 'Data-Cache-Time', $ts );
615  $out->addJsConfigVars( 'dataCacheTime', $ts );
616  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
617  } else {
618  $out->addWikiMsg( 'perfcached', $maxResults );
619  }
620 
621  # If updates on this page have been disabled, let the user know
622  # that the data set won't be refreshed for now
623  if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
624  && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
625  ) {
626  $out->wrapWikiMsg(
627  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
628  'querypage-no-updates'
629  );
630  }
631  }
632  }
633 
634  $this->numRows = $res->numRows();
635 
636  $dbr = $this->getRecacheDB();
637  $this->preprocessResults( $dbr, $res );
638 
639  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
640 
641  # Top header and navigation
642  if ( $this->shownavigation ) {
643  $out->addHTML( $this->getPageHeader() );
644  if ( $this->numRows > 0 ) {
645  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
646  min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
647  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
648  # Disable the "next" link when we reach the end
649  $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
650  && ( $this->offset + $this->limit >= $this->getMaxResults() );
651  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
652  $paging = $this->getLanguage()->viewPrevNext( $this->getPageTitle( $par ), $this->offset,
653  $this->limit, $this->linkParameters(), $atEnd );
654  $out->addHTML( '<p>' . $paging . '</p>' );
655  } else {
656  # No results to show, so don't bother with "showing X of Y" etc.
657  # -- just let the user know and give up now
658  $this->showEmptyText();
659  $out->addHTML( Xml::closeElement( 'div' ) );
660  return;
661  }
662  }
663 
664  # The actual results; specialist subclasses will want to handle this
665  # with more than a straight list, so we hand them the info, plus
666  # an OutputPage, and let them get on with it
667  $this->outputResults( $out,
668  $this->getSkin(),
669  $dbr, # Should use a ResultWrapper for this
670  $res,
671  min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
672  $this->offset );
673 
674  # Repeat the paging links at the bottom
675  if ( $this->shownavigation ) {
676  $out->addHTML( '<p>' . $paging . '</p>' );
677  }
678 
679  $out->addHTML( Xml::closeElement( 'div' ) );
680  }
681 
693  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
694  if ( $num > 0 ) {
695  $html = [];
696  if ( !$this->listoutput ) {
697  $html[] = $this->openList( $offset );
698  }
699 
700  # $res might contain the whole 1,000 rows, so we read up to
701  # $num [should update this to use a Pager]
702  // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
703  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
704  $line = $this->formatResult( $skin, $row );
705  if ( $line ) {
706  $html[] = $this->listoutput
707  ? $line
708  : "<li>{$line}</li>\n";
709  }
710  }
711 
712  # Flush the final result
713  if ( $this->tryLastResult() ) {
714  $row = null;
715  $line = $this->formatResult( $skin, $row );
716  if ( $line ) {
717  $html[] = $this->listoutput
718  ? $line
719  : "<li>{$line}</li>\n";
720  }
721  }
722 
723  if ( !$this->listoutput ) {
724  $html[] = $this->closeList();
725  }
726 
727  $html = $this->listoutput
728  ? MediaWikiServices::getInstance()->getContentLanguage()->listToText( $html )
729  : implode( '', $html );
730 
731  $out->addHTML( $html );
732  }
733  }
734 
739  function openList( $offset ) {
740  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
741  }
742 
746  function closeList() {
747  return "</ol>\n";
748  }
749 
755  function preprocessResults( $db, $res ) {
756  }
757 
764  function doFeed( $class = '', $limit = 50 ) {
765  if ( !$this->getConfig()->get( 'Feed' ) ) {
766  $this->getOutput()->addWikiMsg( 'feed-unavailable' );
767  return false;
768  }
769 
770  $limit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
771 
772  $feedClasses = $this->getConfig()->get( 'FeedClasses' );
773  if ( isset( $feedClasses[$class] ) ) {
775  $feed = new $feedClasses[$class](
776  $this->feedTitle(),
777  $this->feedDesc(),
778  $this->feedUrl() );
779  $feed->outHeader();
780 
781  $res = $this->reallyDoQuery( $limit, 0 );
782  foreach ( $res as $obj ) {
783  $item = $this->feedResult( $obj );
784  if ( $item ) {
785  $feed->outItem( $item );
786  }
787  }
788 
789  $feed->outFooter();
790  return true;
791  } else {
792  return false;
793  }
794  }
795 
802  function feedResult( $row ) {
803  if ( !isset( $row->title ) ) {
804  return null;
805  }
806  $title = Title::makeTitle( intval( $row->namespace ), $row->title );
807  if ( $title ) {
808  $date = $row->timestamp ?? '';
809  $comments = '';
810  if ( $title ) {
811  $talkpage = $title->getTalkPage();
812  $comments = $talkpage->getFullURL();
813  }
814 
815  return new FeedItem(
816  $title->getPrefixedText(),
817  $this->feedItemDesc( $row ),
818  $title->getFullURL(),
819  $date,
820  $this->feedItemAuthor( $row ),
821  $comments );
822  } else {
823  return null;
824  }
825  }
826 
827  function feedItemDesc( $row ) {
828  return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
829  }
830 
831  function feedItemAuthor( $row ) {
832  return $row->user_text ?? '';
833  }
834 
835  function feedTitle() {
836  $desc = $this->getDescription();
837  $code = $this->getConfig()->get( 'LanguageCode' );
838  $sitename = $this->getConfig()->get( 'Sitename' );
839  return "$sitename - $desc [$code]";
840  }
841 
842  function feedDesc() {
843  return $this->msg( 'tagline' )->text();
844  }
845 
846  function feedUrl() {
847  return $this->getPageTitle()->getFullURL();
848  }
849 
860  protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
861  if ( !$res->numRows() ) {
862  return;
863  }
864 
865  $batch = new LinkBatch;
866  foreach ( $res as $row ) {
867  $batch->add( $ns ?? $row->namespace, $row->title );
868  }
869  $batch->execute();
870 
871  $res->seek( 0 );
872  }
873 }
QueryPage\setListoutput
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:119
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:678
QueryPage\$listoutput
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition: QueryPage.php:37
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
FeedItem
A base class for basic support for outputting syndication feeds in RSS and other formats.
Definition: Feed.php:38
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:796
QueryPage\feedTitle
feedTitle()
Definition: QueryPage.php:835
QueryPage\getCacheOrderFields
getCacheOrderFields()
Return the order fields for fetchFromCache.
Definition: QueryPage.php:499
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
QueryPage\$cachedTimestamp
$cachedTimestamp
Definition: QueryPage.php:52
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:249
QueryPage\isCacheable
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:217
QueryPage\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:256
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED since 1.16! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:2042
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1954
QueryPage\linkParameters
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
Definition: QueryPage.php:278
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:693
$tables
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:1018
QueryPage\getLimitOffset
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
Definition: QueryPage.php:525
SpecialPage\displayRestrictionError
displayRestrictionError()
Output an error message telling the user what access level they have to have.
Definition: SpecialPage.php:298
QueryPage\openList
openList( $offset)
Definition: QueryPage.php:739
QueryPage\preprocessResults
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:755
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
QueryPage\execute
execute( $par)
This is the actual workhorse.
Definition: QueryPage.php:574
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:745
$res
$res
Definition: database.txt:21
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:755
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:152
Wikimedia\Rdbms\DBError
Database error base class.
Definition: DBError.php:30
QueryPage\reallyDoQuery
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:394
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:35
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:110
Wikimedia\Rdbms\IDatabase\insert
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
QueryPage\executeLBFromResultWrapper
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include title and ...
Definition: QueryPage.php:860
QueryPage\$offset
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:40
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
$dbr
$dbr
Definition: testCompression.php:50
QueryPage\$limit
int $limit
Definition: QueryPage.php:43
QueryPage\feedItemDesc
feedItemDesc( $row)
Definition: QueryPage.php:827
QueryPage\getCachedTimestamp
getCachedTimestamp()
Definition: QueryPage.php:503
SpecialPage\getDescription
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
Definition: SpecialPage.php:655
QueryPage\closeList
closeList()
Definition: QueryPage.php:746
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1627
Wikimedia\Rdbms\IDatabase\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
$html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:2044
MWException
MediaWiki exception.
Definition: MWException.php:26
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:764
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
QueryPage\getMaxResults
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:564
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
QueryPage\isCached
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:227
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2693
not
if not
Definition: COPYING.txt:307
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:206
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$code
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition: hooks.txt:813
QueryPage\recache
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:305
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:735
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:545
QueryPage\doFeed
doFeed( $class='', $limit=50)
Similar to above, but packaging in a syndicated feed instead of a web page.
Definition: QueryPage.php:764
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
DB_MASTER
const DB_MASTER
Definition: defines.php:26
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
QueryPage\getRecacheDB
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:383
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:121
QueryPage\feedDesc
feedDesc()
Definition: QueryPage.php:842
QueryPage\feedUrl
feedUrl()
Definition: QueryPage.php:846
$line
$line
Definition: cdb.php:59
QueryPage\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:149
QueryPage\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:172
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2221
SpecialPage\userCanExecute
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
Definition: SpecialPage.php:290
$value
$value
Definition: styleTest.css.php:49
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
QueryPage\doQuery
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:445
QueryPage\fetchFromCache
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:460
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:715
QueryPage\feedItemAuthor
feedItemAuthor( $row)
Definition: QueryPage.php:831
QueryPage\showEmptyText
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:267
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1683
QueryPage\feedResult
feedResult( $row)
Override for custom handling.
Definition: QueryPage.php:802
QueryPage\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: QueryPage.php:236
QueryPage\getSQL
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:159
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:119
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:2044
QueryPage\tryLastResult
tryLastResult()
Some special pages (for example SpecialListusers used to) might not return the current object formatt...
Definition: QueryPage.php:293
QueryPage\$shownavigation
$shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:57
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$skin
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition: hooks.txt:2044
QueryPage\usesTimestamps
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
Definition: QueryPage.php:186
$batch
$batch
Definition: linkcache.txt:23
QueryPage\getDBLimit
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:545
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
QueryPage\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:195
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
QueryPage\getPages
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
Definition: QueryPage.php:67
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
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:633
Wikimedia\Rdbms\IDatabase\delete
delete( $table, $conds, $fname=__METHOD__)
DELETE query wrapper.
QueryPage\$numRows
$numRows
The number of rows returned by the query.
Definition: QueryPage.php:50
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:813