MediaWiki REL1_31
QueryPage.php
Go to the documentation of this file.
1<?php
27
34abstract class QueryPage extends SpecialPage {
36 protected $listoutput = false;
37
39 protected $offset = 0;
40
42 protected $limit = 0;
43
49 protected $numRows;
50
51 protected $cachedTimestamp = null;
52
56 protected $shownavigation = true;
57
66 public static function getPages() {
67 static $qp = null;
68
69 if ( $qp === null ) {
70 // QueryPage subclass, Special page name
71 $qp = [
72 [ AncientPagesPage::class, 'Ancientpages' ],
73 [ BrokenRedirectsPage::class, 'BrokenRedirects' ],
74 [ DeadendPagesPage::class, 'Deadendpages' ],
75 [ DoubleRedirectsPage::class, 'DoubleRedirects' ],
76 [ FileDuplicateSearchPage::class, 'FileDuplicateSearch' ],
77 [ ListDuplicatedFilesPage::class, 'ListDuplicatedFiles' ],
78 [ LinkSearchPage::class, 'LinkSearch' ],
79 [ ListredirectsPage::class, 'Listredirects' ],
80 [ LonelyPagesPage::class, 'Lonelypages' ],
81 [ LongPagesPage::class, 'Longpages' ],
82 [ MediaStatisticsPage::class, 'MediaStatistics' ],
83 [ MIMEsearchPage::class, 'MIMEsearch' ],
84 [ MostcategoriesPage::class, 'Mostcategories' ],
85 [ MostimagesPage::class, 'Mostimages' ],
86 [ MostinterwikisPage::class, 'Mostinterwikis' ],
87 [ MostlinkedCategoriesPage::class, 'Mostlinkedcategories' ],
88 [ MostlinkedTemplatesPage::class, 'Mostlinkedtemplates' ],
89 [ MostlinkedPage::class, 'Mostlinked' ],
90 [ MostrevisionsPage::class, 'Mostrevisions' ],
91 [ FewestrevisionsPage::class, 'Fewestrevisions' ],
92 [ ShortPagesPage::class, 'Shortpages' ],
93 [ UncategorizedCategoriesPage::class, 'Uncategorizedcategories' ],
94 [ UncategorizedPagesPage::class, 'Uncategorizedpages' ],
95 [ UncategorizedImagesPage::class, 'Uncategorizedimages' ],
96 [ UncategorizedTemplatesPage::class, 'Uncategorizedtemplates' ],
97 [ UnusedCategoriesPage::class, 'Unusedcategories' ],
98 [ UnusedimagesPage::class, 'Unusedimages' ],
99 [ WantedCategoriesPage::class, 'Wantedcategories' ],
100 [ WantedFilesPage::class, 'Wantedfiles' ],
101 [ WantedPagesPage::class, 'Wantedpages' ],
102 [ WantedTemplatesPage::class, 'Wantedtemplates' ],
103 [ UnwatchedpagesPage::class, 'Unwatchedpages' ],
104 [ UnusedtemplatesPage::class, 'Unusedtemplates' ],
105 [ WithoutInterwikiPage::class, 'Withoutinterwiki' ],
106 ];
107 Hooks::run( 'wgQueryPages', [ &$qp ] );
108 }
109
110 return $qp;
111 }
112
118 function setListoutput( $bool ) {
119 $this->listoutput = $bool;
120 }
121
148 public function getQueryInfo() {
149 return null;
150 }
151
158 function getSQL() {
159 /* Implement getQueryInfo() instead */
160 throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
161 . "getQuery() properly" );
162 }
163
171 function getOrderFields() {
172 return [ 'value' ];
173 }
174
185 public function usesTimestamps() {
186 return false;
187 }
188
194 function sortDescending() {
195 return true;
196 }
197
205 public function isExpensive() {
206 return $this->getConfig()->get( 'DisableQueryPages' );
207 }
208
216 public function isCacheable() {
217 return true;
218 }
219
226 public function isCached() {
227 return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
228 }
229
235 function isSyndicated() {
236 return true;
237 }
238
248 abstract function formatResult( $skin, $result );
249
255 function getPageHeader() {
256 return '';
257 }
258
266 protected function showEmptyText() {
267 $this->getOutput()->addWikiMsg( 'specialpage-empty' );
268 }
269
277 function linkParameters() {
278 return [];
279 }
280
292 function tryLastResult() {
293 return false;
294 }
295
304 public function recache( $limit, $ignoreErrors = true ) {
305 if ( !$this->isCacheable() ) {
306 return 0;
307 }
308
309 $fname = static::class . '::recache';
310 $dbw = wfGetDB( DB_MASTER );
311 if ( !$dbw ) {
312 return false;
313 }
314
315 try {
316 # Do query
317 $res = $this->reallyDoQuery( $limit, false );
318 $num = false;
319 if ( $res ) {
320 $num = $res->numRows();
321 # Fetch results
322 $vals = [];
323 foreach ( $res as $row ) {
324 if ( isset( $row->value ) ) {
325 if ( $this->usesTimestamps() ) {
326 $value = wfTimestamp( TS_UNIX,
327 $row->value );
328 } else {
329 $value = intval( $row->value ); // T16414
330 }
331 } else {
332 $value = 0;
333 }
334
335 $vals[] = [
336 'qc_type' => $this->getName(),
337 'qc_namespace' => $row->namespace,
338 'qc_title' => $row->title,
339 'qc_value' => $value
340 ];
341 }
342
343 $dbw->doAtomicSection(
344 __METHOD__,
345 function ( IDatabase $dbw, $fname ) use ( $vals ) {
346 # Clear out any old cached data
347 $dbw->delete( 'querycache',
348 [ 'qc_type' => $this->getName() ],
349 $fname
350 );
351 # Save results into the querycache table on the master
352 if ( count( $vals ) ) {
353 $dbw->insert( 'querycache', $vals, $fname );
354 }
355 # Update the querycache_info record for the page
356 $dbw->delete( 'querycache_info',
357 [ 'qci_type' => $this->getName() ],
358 $fname
359 );
360 $dbw->insert( 'querycache_info',
361 [ 'qci_type' => $this->getName(),
362 'qci_timestamp' => $dbw->timestamp() ],
363 $fname
364 );
365 }
366 );
367 }
368 } catch ( DBError $e ) {
369 if ( !$ignoreErrors ) {
370 throw $e; // report query error
371 }
372 $num = false; // set result to false to indicate error
373 }
374
375 return $num;
376 }
377
382 function getRecacheDB() {
383 return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
384 }
385
393 public function reallyDoQuery( $limit, $offset = false ) {
394 $fname = static::class . '::reallyDoQuery';
395 $dbr = $this->getRecacheDB();
396 $query = $this->getQueryInfo();
397 $order = $this->getOrderFields();
398
399 if ( $this->sortDescending() ) {
400 foreach ( $order as &$field ) {
401 $field .= ' DESC';
402 }
403 }
404
405 if ( is_array( $query ) ) {
406 $tables = isset( $query['tables'] ) ? (array)$query['tables'] : [];
407 $fields = isset( $query['fields'] ) ? (array)$query['fields'] : [];
408 $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
409 $options = isset( $query['options'] ) ? (array)$query['options'] : [];
410 $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : [];
411
412 if ( $order ) {
413 $options['ORDER BY'] = $order;
414 }
415
416 if ( $limit !== false ) {
417 $options['LIMIT'] = intval( $limit );
418 }
419
420 if ( $offset !== false ) {
421 $options['OFFSET'] = intval( $offset );
422 }
423
424 $res = $dbr->select( $tables, $fields, $conds, $fname,
425 $options, $join_conds
426 );
427 } else {
428 // Old-fashioned raw SQL style, deprecated
429 $sql = $this->getSQL();
430 $sql .= ' ORDER BY ' . implode( ', ', $order );
431 $sql = $dbr->limitResult( $sql, $limit, $offset );
432 $res = $dbr->query( $sql, $fname );
433 }
434
435 return $res;
436 }
437
444 public function doQuery( $offset = false, $limit = false ) {
445 if ( $this->isCached() && $this->isCacheable() ) {
446 return $this->fetchFromCache( $limit, $offset );
447 } else {
448 return $this->reallyDoQuery( $limit, $offset );
449 }
450 }
451
459 public function fetchFromCache( $limit, $offset = false ) {
461 $options = [];
462
463 if ( $limit !== false ) {
464 $options['LIMIT'] = intval( $limit );
465 }
466
467 if ( $offset !== false ) {
468 $options['OFFSET'] = intval( $offset );
469 }
470
471 $order = $this->getCacheOrderFields();
472 if ( $this->sortDescending() ) {
473 foreach ( $order as &$field ) {
474 $field .= " DESC";
475 }
476 }
477 if ( $order ) {
478 $options['ORDER BY'] = $order;
479 }
480
481 return $dbr->select( 'querycache',
482 [ 'qc_type',
483 'namespace' => 'qc_namespace',
484 'title' => 'qc_title',
485 'value' => 'qc_value' ],
486 [ 'qc_type' => $this->getName() ],
487 __METHOD__,
489 );
490 }
491
499 return [ 'value' ];
500 }
501
502 public function getCachedTimestamp() {
503 if ( is_null( $this->cachedTimestamp ) ) {
505 $fname = static::class . '::getCachedTimestamp';
506 $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
507 [ 'qci_type' => $this->getName() ], $fname );
508 }
510 }
511
524 protected function getLimitOffset() {
525 list( $limit, $offset ) = $this->getRequest()->getLimitOffset();
526 if ( $this->getConfig()->get( 'MiserMode' ) ) {
527 $maxResults = $this->getMaxResults();
528 // Can't display more than max results on a page
529 $limit = min( $limit, $maxResults );
530 // Can't skip over more than the end of $maxResults
531 $offset = min( $offset, $maxResults + 1 );
532 }
533 return [ $limit, $offset ];
534 }
535
544 protected function getDBLimit( $uiLimit, $uiOffset ) {
545 $maxResults = $this->getMaxResults();
546 if ( $this->getConfig()->get( 'MiserMode' ) ) {
547 $limit = min( $uiLimit + 1, $maxResults - $uiOffset );
548 return max( $limit, 0 );
549 } else {
550 return $uiLimit + 1;
551 }
552 }
553
563 protected function getMaxResults() {
564 // Max of 10000, unless we store more than 10000 in query cache.
565 return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );
566 }
567
573 public function execute( $par ) {
574 $user = $this->getUser();
575 if ( !$this->userCanExecute( $user ) ) {
577 return;
578 }
579
580 $this->setHeaders();
581 $this->outputHeader();
582
583 $out = $this->getOutput();
584
585 if ( $this->isCached() && !$this->isCacheable() ) {
586 $out->addWikiMsg( 'querypage-disabled' );
587 return;
588 }
589
590 $out->setSyndicated( $this->isSyndicated() );
591
592 if ( $this->limit == 0 && $this->offset == 0 ) {
593 list( $this->limit, $this->offset ) = $this->getLimitOffset();
594 }
595 $dbLimit = $this->getDBLimit( $this->limit, $this->offset );
596 // @todo Use doQuery()
597 if ( !$this->isCached() ) {
598 # select one extra row for navigation
599 $res = $this->reallyDoQuery( $dbLimit, $this->offset );
600 } else {
601 # Get the cached result, select one extra row for navigation
602 $res = $this->fetchFromCache( $dbLimit, $this->offset );
603 if ( !$this->listoutput ) {
604 # Fetch the timestamp of this update
605 $ts = $this->getCachedTimestamp();
606 $lang = $this->getLanguage();
607 $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
608
609 if ( $ts ) {
610 $updated = $lang->userTimeAndDate( $ts, $user );
611 $updateddate = $lang->userDate( $ts, $user );
612 $updatedtime = $lang->userTime( $ts, $user );
613 $out->addMeta( 'Data-Cache-Time', $ts );
614 $out->addJsConfigVars( 'dataCacheTime', $ts );
615 $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
616 } else {
617 $out->addWikiMsg( 'perfcached', $maxResults );
618 }
619
620 # If updates on this page have been disabled, let the user know
621 # that the data set won't be refreshed for now
622 if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
623 && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
624 ) {
625 $out->wrapWikiMsg(
626 "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
627 'querypage-no-updates'
628 );
629 }
630 }
631 }
632
633 $this->numRows = $res->numRows();
634
635 $dbr = $this->getRecacheDB();
636 $this->preprocessResults( $dbr, $res );
637
638 $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) );
639
640 # Top header and navigation
641 if ( $this->shownavigation ) {
642 $out->addHTML( $this->getPageHeader() );
643 if ( $this->numRows > 0 ) {
644 $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
645 min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
646 $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
647 # Disable the "next" link when we reach the end
648 $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
649 && ( $this->offset + $this->limit >= $this->getMaxResults() );
650 $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
651 $paging = $this->getLanguage()->viewPrevNext( $this->getPageTitle( $par ), $this->offset,
652 $this->limit, $this->linkParameters(), $atEnd );
653 $out->addHTML( '<p>' . $paging . '</p>' );
654 } else {
655 # No results to show, so don't bother with "showing X of Y" etc.
656 # -- just let the user know and give up now
657 $this->showEmptyText();
658 $out->addHTML( Xml::closeElement( 'div' ) );
659 return;
660 }
661 }
662
663 # The actual results; specialist subclasses will want to handle this
664 # with more than a straight list, so we hand them the info, plus
665 # an OutputPage, and let them get on with it
666 $this->outputResults( $out,
667 $this->getSkin(),
668 $dbr, # Should use a ResultWrapper for this
669 $res,
670 min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
671 $this->offset );
672
673 # Repeat the paging links at the bottom
674 if ( $this->shownavigation ) {
675 $out->addHTML( '<p>' . $paging . '</p>' );
676 }
677
678 $out->addHTML( Xml::closeElement( 'div' ) );
679 }
680
692 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
694
695 if ( $num > 0 ) {
696 $html = [];
697 if ( !$this->listoutput ) {
698 $html[] = $this->openList( $offset );
699 }
700
701 # $res might contain the whole 1,000 rows, so we read up to
702 # $num [should update this to use a Pager]
703 // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
704 for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
705 $line = $this->formatResult( $skin, $row );
706 if ( $line ) {
707 $html[] = $this->listoutput
708 ? $line
709 : "<li>{$line}</li>\n";
710 }
711 }
712
713 # Flush the final result
714 if ( $this->tryLastResult() ) {
715 $row = null;
716 $line = $this->formatResult( $skin, $row );
717 if ( $line ) {
718 $html[] = $this->listoutput
719 ? $line
720 : "<li>{$line}</li>\n";
721 }
722 }
723
724 if ( !$this->listoutput ) {
725 $html[] = $this->closeList();
726 }
727
728 $html = $this->listoutput
729 ? $wgContLang->listToText( $html )
730 : implode( '', $html );
731
732 $out->addHTML( $html );
733 }
734 }
735
740 function openList( $offset ) {
741 return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
742 }
743
747 function closeList() {
748 return "</ol>\n";
749 }
750
756 function preprocessResults( $db, $res ) {
757 }
758
765 function doFeed( $class = '', $limit = 50 ) {
766 if ( !$this->getConfig()->get( 'Feed' ) ) {
767 $this->getOutput()->addWikiMsg( 'feed-unavailable' );
768 return false;
769 }
770
771 $limit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
772
773 $feedClasses = $this->getConfig()->get( 'FeedClasses' );
774 if ( isset( $feedClasses[$class] ) ) {
776 $feed = new $feedClasses[$class](
777 $this->feedTitle(),
778 $this->feedDesc(),
779 $this->feedUrl() );
780 $feed->outHeader();
781
782 $res = $this->reallyDoQuery( $limit, 0 );
783 foreach ( $res as $obj ) {
784 $item = $this->feedResult( $obj );
785 if ( $item ) {
786 $feed->outItem( $item );
787 }
788 }
789
790 $feed->outFooter();
791 return true;
792 } else {
793 return false;
794 }
795 }
796
803 function feedResult( $row ) {
804 if ( !isset( $row->title ) ) {
805 return null;
806 }
807 $title = Title::makeTitle( intval( $row->namespace ), $row->title );
808 if ( $title ) {
809 $date = isset( $row->timestamp ) ? $row->timestamp : '';
810 $comments = '';
811 if ( $title ) {
812 $talkpage = $title->getTalkPage();
813 $comments = $talkpage->getFullURL();
814 }
815
816 return new FeedItem(
817 $title->getPrefixedText(),
818 $this->feedItemDesc( $row ),
819 $title->getFullURL(),
820 $date,
821 $this->feedItemAuthor( $row ),
822 $comments );
823 } else {
824 return null;
825 }
826 }
827
828 function feedItemDesc( $row ) {
829 return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
830 }
831
832 function feedItemAuthor( $row ) {
833 return isset( $row->user_text ) ? $row->user_text : '';
834 }
835
836 function feedTitle() {
837 $desc = $this->getDescription();
838 $code = $this->getConfig()->get( 'LanguageCode' );
839 $sitename = $this->getConfig()->get( 'Sitename' );
840 return "$sitename - $desc [$code]";
841 }
842
843 function feedDesc() {
844 return $this->msg( 'tagline' )->text();
845 }
846
847 function feedUrl() {
848 return $this->getPageTitle()->getFullURL();
849 }
850
861 protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
862 if ( !$res->numRows() ) {
863 return;
864 }
865
866 $batch = new LinkBatch;
867 foreach ( $res as $row ) {
868 $batch->add( $ns !== null ? $ns : $row->namespace, $row->title );
869 }
870 $batch->execute();
871
872 $res->seek( 0 );
873 }
874}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:112
$line
Definition cdb.php:59
A base class for basic support for outputting syndication feeds in RSS and other formats.
Definition Feed.php:38
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
add( $ns, $dbkey)
Definition LinkBatch.php:80
MediaWiki exception.
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:34
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array.
getMaxResults()
Get max number of results we can return in miser mode.
doQuery( $offset=false, $limit=false)
Somewhat deprecated, you probably want to be using execute()
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include title and ...
setListoutput( $bool)
A mutator for $this->listoutput;.
recache( $limit, $ignoreErrors=true)
Clear the cache and save new results.
tryLastResult()
Some special pages (for example SpecialListusers used to) might not return the current object formatt...
fetchFromCache( $limit, $offset=false)
Fetch the query results from the query cache.
int $offset
The offset and limit in use, as passed to the query() function.
Definition QueryPage.php:39
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
$shownavigation
Whether to show prev/next links.
Definition QueryPage.php:56
doFeed( $class='', $limit=50)
Similar to above, but packaging in a syndicated feed instead of a web page.
sortDescending()
Override to sort by increasing values.
formatResult( $skin, $result)
Formats the results of the query for display.
isSyndicated()
Sometime we don't want to build rss / atom feeds.
getCachedTimestamp()
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
Definition QueryPage.php:66
reallyDoQuery( $limit, $offset=false)
Run the query and return the result.
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
getOrderFields()
Subclasses return an array of fields to order by here.
showEmptyText()
Outputs some kind of an informative message (via OutputPage) to let the user know that the query retu...
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
getCacheOrderFields()
Return the order fields for fetchFromCache.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
openList( $offset)
getDBLimit( $uiLimit, $uiOffset)
What is limit to fetch from DB.
feedItemDesc( $row)
$numRows
The number of rows returned by the query.
Definition QueryPage.php:49
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
feedItemAuthor( $row)
getSQL()
For back-compat, subclasses may return a raw SQL query here, as a string.
getPageHeader()
The content returned by this function will be output before any result.
bool $listoutput
Whether or not we want plain listoutput rather than an ordered list.
Definition QueryPage.php:36
execute( $par)
This is the actual workhorse.
feedResult( $row)
Override for custom handling.
getLimitOffset()
Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
getRecacheDB()
Get a DB connection to be used for slow recache queries.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getName()
Get the name of this Special Page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
displayRestrictionError()
Output an error message telling the user what access level they have to have.
getPageTitle( $subpage=false)
Get a self-referential title object.
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...
Database error base class.
Definition DBError.php:30
$res
Definition database.txt:21
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
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:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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! 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! 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:1993
this hook is for auditing only RecentChangesLinked and Watchlist 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:1015
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:2001
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:865
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
if the prop value should be in the metadata multi language array format
Definition hooks.txt:1656
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:864
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:2013
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:2011
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:1620
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:247
returning false will NOT prevent logging $e
Definition hooks.txt:2176
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:37
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
delete( $table, $conds, $fname=__METHOD__)
DELETE query wrapper.
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
Result wrapper for grabbing data queried from an IDatabase object.
$batch
Definition linkcache.txt:23
const DB_REPLICA
Definition defines.php:25
const DB_MASTER
Definition defines.php:29
if(!isset( $args[0])) $lang