MediaWiki  1.27.2
QueryPage.php
Go to the documentation of this file.
1 <?php
30 abstract class QueryPage extends SpecialPage {
32  protected $listoutput = false;
33 
35  protected $offset = 0;
36 
38  protected $limit = 0;
39 
45  protected $numRows;
46 
47  protected $cachedTimestamp = null;
48 
52  protected $shownavigation = true;
53 
62  public static function getPages() {
63  static $qp = null;
64 
65  if ( $qp === null ) {
66  // QueryPage subclass, Special page name
67  $qp = [
68  [ 'AncientPagesPage', 'Ancientpages' ],
69  [ 'BrokenRedirectsPage', 'BrokenRedirects' ],
70  [ 'DeadendPagesPage', 'Deadendpages' ],
71  [ 'DoubleRedirectsPage', 'DoubleRedirects' ],
72  [ 'FileDuplicateSearchPage', 'FileDuplicateSearch' ],
73  [ 'ListDuplicatedFilesPage', 'ListDuplicatedFiles' ],
74  [ 'LinkSearchPage', 'LinkSearch' ],
75  [ 'ListredirectsPage', 'Listredirects' ],
76  [ 'LonelyPagesPage', 'Lonelypages' ],
77  [ 'LongPagesPage', 'Longpages' ],
78  [ 'MediaStatisticsPage', 'MediaStatistics' ],
79  [ 'MIMEsearchPage', 'MIMEsearch' ],
80  [ 'MostcategoriesPage', 'Mostcategories' ],
81  [ 'MostimagesPage', 'Mostimages' ],
82  [ 'MostinterwikisPage', 'Mostinterwikis' ],
83  [ 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ],
84  [ 'MostlinkedTemplatesPage', 'Mostlinkedtemplates' ],
85  [ 'MostlinkedPage', 'Mostlinked' ],
86  [ 'MostrevisionsPage', 'Mostrevisions' ],
87  [ 'FewestrevisionsPage', 'Fewestrevisions' ],
88  [ 'ShortPagesPage', 'Shortpages' ],
89  [ 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ],
90  [ 'UncategorizedPagesPage', 'Uncategorizedpages' ],
91  [ 'UncategorizedImagesPage', 'Uncategorizedimages' ],
92  [ 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ],
93  [ 'UnusedCategoriesPage', 'Unusedcategories' ],
94  [ 'UnusedimagesPage', 'Unusedimages' ],
95  [ 'WantedCategoriesPage', 'Wantedcategories' ],
96  [ 'WantedFilesPage', 'Wantedfiles' ],
97  [ 'WantedPagesPage', 'Wantedpages' ],
98  [ 'WantedTemplatesPage', 'Wantedtemplates' ],
99  [ 'UnwatchedpagesPage', 'Unwatchedpages' ],
100  [ 'UnusedtemplatesPage', 'Unusedtemplates' ],
101  [ 'WithoutInterwikiPage', 'Withoutinterwiki' ],
102  ];
103  Hooks::run( 'wgQueryPages', [ &$qp ] );
104  }
105 
106  return $qp;
107  }
108 
114  function setListoutput( $bool ) {
115  $this->listoutput = $bool;
116  }
117 
144  public function getQueryInfo() {
145  return null;
146  }
147 
154  function getSQL() {
155  /* Implement getQueryInfo() instead */
156  throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
157  . "getQuery() properly" );
158  }
159 
167  function getOrderFields() {
168  return [ 'value' ];
169  }
170 
181  public function usesTimestamps() {
182  return false;
183  }
184 
190  function sortDescending() {
191  return true;
192  }
193 
201  public function isExpensive() {
202  return $this->getConfig()->get( 'DisableQueryPages' );
203  }
204 
212  public function isCacheable() {
213  return true;
214  }
215 
222  public function isCached() {
223  return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
224  }
225 
231  function isSyndicated() {
232  return true;
233  }
234 
244  abstract function formatResult( $skin, $result );
245 
251  function getPageHeader() {
252  return '';
253  }
254 
262  protected function showEmptyText() {
263  $this->getOutput()->addWikiMsg( 'specialpage-empty' );
264  }
265 
273  function linkParameters() {
274  return [];
275  }
276 
288  function tryLastResult() {
289  return false;
290  }
291 
300  public function recache( $limit, $ignoreErrors = true ) {
301  if ( !$this->isCacheable() ) {
302  return 0;
303  }
304 
305  $fname = get_class( $this ) . '::recache';
306  $dbw = wfGetDB( DB_MASTER );
307  if ( !$dbw ) {
308  return false;
309  }
310 
311  try {
312  # Do query
313  $res = $this->reallyDoQuery( $limit, false );
314  $num = false;
315  if ( $res ) {
316  $num = $res->numRows();
317  # Fetch results
318  $vals = [];
319  foreach ( $res as $row ) {
320  if ( isset( $row->value ) ) {
321  if ( $this->usesTimestamps() ) {
323  $row->value );
324  } else {
325  $value = intval( $row->value ); // @bug 14414
326  }
327  } else {
328  $value = 0;
329  }
330 
331  $vals[] = [
332  'qc_type' => $this->getName(),
333  'qc_namespace' => $row->namespace,
334  'qc_title' => $row->title,
335  'qc_value' => $value
336  ];
337  }
338 
339  $dbw->doAtomicSection(
340  __METHOD__,
341  function ( IDatabase $dbw, $fname ) use ( $vals ) {
342  # Clear out any old cached data
343  $dbw->delete( 'querycache',
344  [ 'qc_type' => $this->getName() ],
345  $fname
346  );
347  # Save results into the querycache table on the master
348  if ( count( $vals ) ) {
349  $dbw->insert( 'querycache', $vals, $fname );
350  }
351  # Update the querycache_info record for the page
352  $dbw->delete( 'querycache_info',
353  [ 'qci_type' => $this->getName() ],
354  $fname
355  );
356  $dbw->insert( 'querycache_info',
357  [ 'qci_type' => $this->getName(),
358  'qci_timestamp' => $dbw->timestamp() ],
359  $fname
360  );
361  }
362  );
363  }
364  } catch ( DBError $e ) {
365  if ( !$ignoreErrors ) {
366  throw $e; // report query error
367  }
368  $num = false; // set result to false to indicate error
369  }
370 
371  return $num;
372  }
373 
378  function getRecacheDB() {
379  return wfGetDB( DB_SLAVE, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
380  }
381 
389  public function reallyDoQuery( $limit, $offset = false ) {
390  $fname = get_class( $this ) . "::reallyDoQuery";
391  $dbr = $this->getRecacheDB();
392  $query = $this->getQueryInfo();
393  $order = $this->getOrderFields();
394 
395  if ( $this->sortDescending() ) {
396  foreach ( $order as &$field ) {
397  $field .= ' DESC';
398  }
399  }
400 
401  if ( is_array( $query ) ) {
402  $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
403  $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
404  $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
405  $options = isset( $query['options'] ) ? (array)$query['options'] : [];
406  $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
407 
408  if ( count( $order ) ) {
409  $options['ORDER BY'] = $order;
410  }
411 
412  if ( $limit !== false ) {
413  $options['LIMIT'] = intval( $limit );
414  }
415 
416  if ( $offset !== false ) {
417  $options['OFFSET'] = intval( $offset );
418  }
419 
420  $res = $dbr->select( $tables, $fields, $conds, $fname,
421  $options, $join_conds
422  );
423  } else {
424  // Old-fashioned raw SQL style, deprecated
425  $sql = $this->getSQL();
426  $sql .= ' ORDER BY ' . implode( ', ', $order );
427  $sql = $dbr->limitResult( $sql, $limit, $offset );
428  $res = $dbr->query( $sql, $fname );
429  }
430 
431  return $res;
432  }
433 
440  public function doQuery( $offset = false, $limit = false ) {
441  if ( $this->isCached() && $this->isCacheable() ) {
442  return $this->fetchFromCache( $limit, $offset );
443  } else {
444  return $this->reallyDoQuery( $limit, $offset );
445  }
446  }
447 
455  public function fetchFromCache( $limit, $offset = false ) {
456  $dbr = wfGetDB( DB_SLAVE );
457  $options = [];
458  if ( $limit !== false ) {
459  $options['LIMIT'] = intval( $limit );
460  }
461  if ( $offset !== false ) {
462  $options['OFFSET'] = intval( $offset );
463  }
464  if ( $this->sortDescending() ) {
465  $options['ORDER BY'] = 'qc_value DESC';
466  } else {
467  $options['ORDER BY'] = 'qc_value ASC';
468  }
469  return $dbr->select( 'querycache', [ 'qc_type',
470  'namespace' => 'qc_namespace',
471  'title' => 'qc_title',
472  'value' => 'qc_value' ],
473  [ 'qc_type' => $this->getName() ],
474  __METHOD__, $options
475  );
476  }
477 
478  public function getCachedTimestamp() {
479  if ( is_null( $this->cachedTimestamp ) ) {
480  $dbr = wfGetDB( DB_SLAVE );
481  $fname = get_class( $this ) . '::getCachedTimestamp';
482  $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
483  [ 'qci_type' => $this->getName() ], $fname );
484  }
485  return $this->cachedTimestamp;
486  }
487 
500  protected function getLimitOffset() {
501  list( $limit, $offset ) = $this->getRequest()->getLimitOffset();
502  if ( $this->getConfig()->get( 'MiserMode' ) ) {
503  $maxResults = $this->getMaxResults();
504  // Can't display more than max results on a page
505  $limit = min( $limit, $maxResults );
506  // Can't skip over more than the end of $maxResults
507  $offset = min( $offset, $maxResults + 1 );
508  }
509  return [ $limit, $offset ];
510  }
511 
520  protected function getDBLimit( $uiLimit, $uiOffset ) {
521  $maxResults = $this->getMaxResults();
522  if ( $this->getConfig()->get( 'MiserMode' ) ) {
523  $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
524  return max( $limit, 0 );
525  } else {
526  return $uiLimit + 1;
527  }
528  }
529 
539  protected function getMaxResults() {
540  // Max of 10000, unless we store more than 10000 in query cache.
541  return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
542  }
543 
549  public function execute( $par ) {
550  $user = $this->getUser();
551  if ( !$this->userCanExecute( $user ) ) {
552  $this->displayRestrictionError();
553  return;
554  }
555 
556  $this->setHeaders();
557  $this->outputHeader();
558 
559  $out = $this->getOutput();
560 
561  if ( $this->isCached() && !$this->isCacheable() ) {
562  $out->addWikiMsg( 'querypage-disabled' );
563  return;
564  }
565 
566  $out->setSyndicated( $this->isSyndicated() );
567 
568  if ( $this->limit == 0 && $this->offset == 0 ) {
569  list( $this->limit, $this->offset ) = $this->getLimitOffset();
570  }
571  $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
572  // @todo Use doQuery()
573  if ( !$this->isCached() ) {
574  # select one extra row for navigation
575  $res = $this->reallyDoQuery( $dbLimit, $this->offset );
576  } else {
577  # Get the cached result, select one extra row for navigation
578  $res = $this->fetchFromCache( $dbLimit, $this->offset );
579  if ( !$this->listoutput ) {
580 
581  # Fetch the timestamp of this update
582  $ts = $this->getCachedTimestamp();
583  $lang = $this->getLanguage();
584  $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
585 
586  if ( $ts ) {
587  $updated = $lang->userTimeAndDate( $ts, $user );
588  $updateddate = $lang->userDate( $ts, $user );
589  $updatedtime = $lang->userTime( $ts, $user );
590  $out->addMeta( 'Data-Cache-Time', $ts );
591  $out->addJsConfigVars( 'dataCacheTime', $ts );
592  $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
593  } else {
594  $out->addWikiMsg( 'perfcached', $maxResults );
595  }
596 
597  # If updates on this page have been disabled, let the user know
598  # that the data set won't be refreshed for now
599  if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
600  && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
601  ) {
602  $out->wrapWikiMsg(
603  "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
604  'querypage-no-updates'
605  );
606  }
607  }
608  }
609 
610  $this->numRows = $res->numRows();
611 
612  $dbr = $this->getRecacheDB();
613  $this->preprocessResults( $dbr, $res );
614 
615  $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
616 
617  # Top header and navigation
618  if ( $this->shownavigation ) {
619  $out->addHTML( $this->getPageHeader() );
620  if ( $this->numRows > 0 ) {
621  $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
622  min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
623  $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
624  # Disable the "next" link when we reach the end
625  $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
626  && ( $this->offset + $this->limit >= $this->getMaxResults() );
627  $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
628  $paging = $this->getLanguage()->viewPrevNext( $this->getPageTitle( $par ), $this->offset,
629  $this->limit, $this->linkParameters(), $atEnd );
630  $out->addHTML( '<p>' . $paging . '</p>' );
631  } else {
632  # No results to show, so don't bother with "showing X of Y" etc.
633  # -- just let the user know and give up now
634  $this->showEmptyText();
635  $out->addHTML( Xml::closeElement( 'div' ) );
636  return;
637  }
638  }
639 
640  # The actual results; specialist subclasses will want to handle this
641  # with more than a straight list, so we hand them the info, plus
642  # an OutputPage, and let them get on with it
643  $this->outputResults( $out,
644  $this->getSkin(),
645  $dbr, # Should use a ResultWrapper for this
646  $res,
647  min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
648  $this->offset );
649 
650  # Repeat the paging links at the bottom
651  if ( $this->shownavigation ) {
652  $out->addHTML( '<p>' . $paging . '</p>' );
653  }
654 
655  $out->addHTML( Xml::closeElement( 'div' ) );
656  }
657 
669  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
671 
672  if ( $num > 0 ) {
673  $html = [];
674  if ( !$this->listoutput ) {
675  $html[] = $this->openList( $offset );
676  }
677 
678  # $res might contain the whole 1,000 rows, so we read up to
679  # $num [should update this to use a Pager]
680  // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
681  for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
682  // @codingStandardsIgnoreEnd
683  $line = $this->formatResult( $skin, $row );
684  if ( $line ) {
685  $html[] = $this->listoutput
686  ? $line
687  : "<li>{$line}</li>\n";
688  }
689  }
690 
691  # Flush the final result
692  if ( $this->tryLastResult() ) {
693  $row = null;
694  $line = $this->formatResult( $skin, $row );
695  if ( $line ) {
696  $html[] = $this->listoutput
697  ? $line
698  : "<li>{$line}</li>\n";
699  }
700  }
701 
702  if ( !$this->listoutput ) {
703  $html[] = $this->closeList();
704  }
705 
706  $html = $this->listoutput
707  ? $wgContLang->listToText( $html )
708  : implode( '', $html );
709 
710  $out->addHTML( $html );
711  }
712  }
713 
718  function openList( $offset ) {
719  return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
720  }
721 
725  function closeList() {
726  return "</ol>\n";
727  }
728 
734  function preprocessResults( $db, $res ) {
735  }
736 
743  function doFeed( $class = '', $limit = 50 ) {
744  if ( !$this->getConfig()->get( 'Feed' ) ) {
745  $this->getOutput()->addWikiMsg( 'feed-unavailable' );
746  return false;
747  }
748 
749  $limit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
750 
751  $feedClasses = $this->getConfig()->get( 'FeedClasses' );
752  if ( isset( $feedClasses[$class] ) ) {
754  $feed = new $feedClasses[$class](
755  $this->feedTitle(),
756  $this->feedDesc(),
757  $this->feedUrl() );
758  $feed->outHeader();
759 
760  $res = $this->reallyDoQuery( $limit, 0 );
761  foreach ( $res as $obj ) {
762  $item = $this->feedResult( $obj );
763  if ( $item ) {
764  $feed->outItem( $item );
765  }
766  }
767 
768  $feed->outFooter();
769  return true;
770  } else {
771  return false;
772  }
773  }
774 
781  function feedResult( $row ) {
782  if ( !isset( $row->title ) ) {
783  return null;
784  }
785  $title = Title::makeTitle( intval( $row->namespace ), $row->title );
786  if ( $title ) {
787  $date = isset( $row->timestamp ) ? $row->timestamp : '';
788  $comments = '';
789  if ( $title ) {
790  $talkpage = $title->getTalkPage();
791  $comments = $talkpage->getFullURL();
792  }
793 
794  return new FeedItem(
795  $title->getPrefixedText(),
796  $this->feedItemDesc( $row ),
797  $title->getFullURL(),
798  $date,
799  $this->feedItemAuthor( $row ),
800  $comments );
801  } else {
802  return null;
803  }
804  }
805 
806  function feedItemDesc( $row ) {
807  return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
808  }
809 
810  function feedItemAuthor( $row ) {
811  return isset( $row->user_text ) ? $row->user_text : '';
812  }
813 
814  function feedTitle() {
815  $desc = $this->getDescription();
816  $code = $this->getConfig()->get( 'LanguageCode' );
817  $sitename = $this->getConfig()->get( 'Sitename' );
818  return "$sitename - $desc [$code]";
819  }
820 
821  function feedDesc() {
822  return $this->msg( 'tagline' )->text();
823  }
824 
825  function feedUrl() {
826  return $this->getPageTitle()->getFullURL();
827  }
828 }
#define the
table suitable for use with IDatabase::select()
insert($table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
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:1798
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
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:762
Database error base class.
the array() calling protocol came about after MediaWiki 1.4rc1.
null for the local 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:1418
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1932
if(!isset($args[0])) $lang
getDBLimit($uiLimit, $uiOffset)
What is limit to fetch from DB.
Definition: QueryPage.php:520
doQuery($offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
Definition: QueryPage.php:440
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: QueryPage.php:167
$numRows
The number of rows returned by the query.
Definition: QueryPage.php:45
getMaxResults()
Get max number of results we can return in miser mode.
Definition: QueryPage.php:539
$value
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:222
feedResult($row)
Override for custom handling.
Definition: QueryPage.php:781
feedItemDesc($row)
Definition: QueryPage.php:806
reallyDoQuery($limit, $offset=false)
Run the query and return the result.
Definition: QueryPage.php:389
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
timestamp($ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:965
fetchFromCache($limit, $offset=false)
Fetch the query results from the query cache.
Definition: QueryPage.php:455
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. '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 '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!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:Associative array mapping language codes to prefixed links of the form"language:title".&$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':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:1796
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
Definition: QueryPage.php:262
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
Definition: QueryPage.php:500
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
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:30
formatResult($skin, $result)
Formats the results of the query for display.
recache($limit, $ignoreErrors=true)
Clear the cache and save new results.
Definition: QueryPage.php:300
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Definition: QueryPage.php:378
static closeElement($element)
Shortcut to close an XML element.
Definition: Xml.php:118
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array...
Definition: QueryPage.php:273
delete($table, $conds, $fname=__METHOD__)
DELETE query wrapper.
Parent class for all special pages.
Definition: SpecialPage.php:36
feedItemAuthor($row)
Definition: QueryPage.php:810
tryLastResult()
Some special pages (for example SpecialListusers used to) might not return the current object formatt...
Definition: QueryPage.php:288
displayRestrictionError()
Output an error message telling the user what access level they have to have.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1004
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: QueryPage.php:144
$res
Definition: database.txt:21
static openElement($element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
$cachedTimestamp
Definition: QueryPage.php:47
setListoutput($bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:114
sortDescending()
Override to sort by increasing values.
Definition: QueryPage.php:190
getSkin()
Shortcut to get the skin being used for this instance.
getDescription()
Returns the name that goes in the \ in the special page itself, and also the name that will be l...
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:35
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
getPageHeader()
The content returned by this function will be output before any result.
Definition: QueryPage.php:251
const DB_SLAVE
Definition: Defines.php:46
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
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:1798
A base class for basic support for outputting syndication feeds in RSS and other formats.
Definition: Feed.php:38
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
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:762
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 local account $user
Definition: hooks.txt:242
doFeed($class= '', $limit=50)
Similar to above, but packaging in a syndicated feed instead of a web page.
Definition: QueryPage.php:743
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
$shownavigation
Whether to show prev/next links.
Definition: QueryPage.php:52
getName()
Get the name of this Special Page.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
Definition: Setup.php:35
getUser()
Shortcut to get the User executing this instance.
outputResults($out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: QueryPage.php:669
$line
Definition: cdb.php:59
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition: QueryPage.php:32
getConfig()
Shortcut to get main config object.
int $limit
Definition: QueryPage.php:38
getLanguage()
Shortcut to get user's language.
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition: design.txt:56
preprocessResults($db, $res)
Do any necessary preprocessing of the result object.
Definition: QueryPage.php:734
const DB_MASTER
Definition: Defines.php:47
execute($par)
This is the actual workhorse.
Definition: QueryPage.php:549
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true, this class will convert 'value' to a UNIX timestamp for caching.
Definition: QueryPage.php:181
getCachedTimestamp()
Definition: QueryPage.php:478
Result wrapper for grabbing data queried by someone else.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
!html< table >< tr >< tdstyle="color:red;"></td >< tdstyle="color:blue;"></td ></tr >< tr >< td ></td >< td ></td >< td ></td >< td ></td >< td ></td >< td ></td ></tr >< tr >< td ></td >< td ></td ></tr ></table >!end!test Table rowspan row</td >< tdrowspan="2"> row(and 2)</td >< td > Cell 3
getRequest()
Get the WebRequest being used for this instance.
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
Definition: QueryPage.php:154
openList($offset)
Definition: QueryPage.php:718
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode...
Definition: QueryPage.php:201
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
Definition: QueryPage.php:212
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:524
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: QueryPage.php:231
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates...
Definition: QueryPage.php:62
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1473
Basic database interface for live and lazy-loaded DB handles.
Definition: IDatabase.php:35
getPageTitle($subpage=false)
Get a self-referential title object.