Merge "filebackend: cleaned up the FileBackend constructor"
[mediawiki.git] / includes / QueryPage.php
blobb8e4e60c48980b287f6cac527301b9302ced833c
1 <?php
2 /**
3 * Base code for "query" special pages.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * List of query page classes and their associated special pages,
26 * for periodic updates.
28 * DO NOT CHANGE THIS LIST without testing that
29 * maintenance/updateSpecialPages.php still works.
31 global $wgQueryPages; // not redundant
32 $wgQueryPages = array(
33 // QueryPage subclass, Special page name, Limit (false for none, none for the default)
34 // ----------------------------------------------------------------------------
35 array( 'AncientPagesPage', 'Ancientpages' ),
36 array( 'BrokenRedirectsPage', 'BrokenRedirects' ),
37 array( 'DeadendPagesPage', 'Deadendpages' ),
38 array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
39 array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
40 array( 'LinkSearchPage', 'LinkSearch' ),
41 array( 'ListredirectsPage', 'Listredirects' ),
42 array( 'LonelyPagesPage', 'Lonelypages' ),
43 array( 'LongPagesPage', 'Longpages' ),
44 array( 'MIMEsearchPage', 'MIMEsearch' ),
45 array( 'MostcategoriesPage', 'Mostcategories' ),
46 array( 'MostimagesPage', 'Mostimages' ),
47 array( 'MostinterwikisPage', 'Mostinterwikis' ),
48 array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
49 array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ),
50 array( 'MostlinkedPage', 'Mostlinked' ),
51 array( 'MostrevisionsPage', 'Mostrevisions' ),
52 array( 'FewestrevisionsPage', 'Fewestrevisions' ),
53 array( 'ShortPagesPage', 'Shortpages' ),
54 array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ),
55 array( 'UncategorizedPagesPage', 'Uncategorizedpages' ),
56 array( 'UncategorizedImagesPage', 'Uncategorizedimages' ),
57 array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ),
58 array( 'UnusedCategoriesPage', 'Unusedcategories' ),
59 array( 'UnusedimagesPage', 'Unusedimages' ),
60 array( 'WantedCategoriesPage', 'Wantedcategories' ),
61 array( 'WantedFilesPage', 'Wantedfiles' ),
62 array( 'WantedPagesPage', 'Wantedpages' ),
63 array( 'WantedTemplatesPage', 'Wantedtemplates' ),
64 array( 'UnwatchedPagesPage', 'Unwatchedpages' ),
65 array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
66 array( 'WithoutInterwikiPage', 'Withoutinterwiki' ),
68 wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
70 global $wgDisableCounters;
71 if ( !$wgDisableCounters ) {
72 $wgQueryPages[] = array( 'PopularPagesPage', 'Popularpages' );
75 /**
76 * This is a class for doing query pages; since they're almost all the same,
77 * we factor out some of the functionality into a superclass, and let
78 * subclasses derive from it.
79 * @ingroup SpecialPage
81 abstract class QueryPage extends SpecialPage {
82 /**
83 * Whether or not we want plain listoutput rather than an ordered list
85 * @var bool
87 var $listoutput = false;
89 /**
90 * The offset and limit in use, as passed to the query() function
92 * @var int
94 var $offset = 0;
95 var $limit = 0;
97 /**
98 * The number of rows returned by the query. Reading this variable
99 * only makes sense in functions that are run after the query has been
100 * done, such as preprocessResults() and formatRow().
102 protected $numRows;
104 protected $cachedTimestamp = null;
107 * Wheter to show prev/next links
109 protected $shownavigation = true;
112 * A mutator for $this->listoutput;
114 * @param bool $bool
116 function setListoutput( $bool ) {
117 $this->listoutput = $bool;
121 * Subclasses return an SQL query here, formatted as an array with the
122 * following keys:
123 * tables => Table(s) for passing to Database::select()
124 * fields => Field(s) for passing to Database::select(), may be *
125 * conds => WHERE conditions
126 * options => options
127 * join_conds => JOIN conditions
129 * Note that the query itself should return the following three columns:
130 * 'namespace', 'title', and 'value'. 'value' is used for sorting.
132 * These may be stored in the querycache table for expensive queries,
133 * and that cached data will be returned sometimes, so the presence of
134 * extra fields can't be relied upon. The cached 'value' column will be
135 * an integer; non-numeric values are useful only for sorting the
136 * initial query (except if they're timestamps, see usesTimestamps()).
138 * Don't include an ORDER or LIMIT clause, they will be added.
140 * If this function is not overridden or returns something other than
141 * an array, getSQL() will be used instead. This is for backwards
142 * compatibility only and is strongly deprecated.
143 * @return array
144 * @since 1.18
146 function getQueryInfo() {
147 return null;
151 * For back-compat, subclasses may return a raw SQL query here, as a string.
152 * This is strongly deprecated; getQueryInfo() should be overridden instead.
153 * @throws MWException
154 * @return string
156 function getSQL() {
157 /* Implement getQueryInfo() instead */
158 throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
159 . "getQuery() properly" );
163 * Subclasses return an array of fields to order by here. Don't append
164 * DESC to the field names, that'll be done automatically if
165 * sortDescending() returns true.
166 * @return array
167 * @since 1.18
169 function getOrderFields() {
170 return array( 'value' );
174 * Does this query return timestamps rather than integers in its
175 * 'value' field? If true, this class will convert 'value' to a
176 * UNIX timestamp for caching.
177 * NOTE: formatRow() may get timestamps in TS_MW (mysql), TS_DB (pgsql)
178 * or TS_UNIX (querycache) format, so be sure to always run them
179 * through wfTimestamp()
180 * @return bool
181 * @since 1.18
183 function usesTimestamps() {
184 return false;
188 * Override to sort by increasing values
190 * @return bool
192 function sortDescending() {
193 return true;
197 * Is this query expensive (for some definition of expensive)? Then we
198 * don't let it run in miser mode. $wgDisableQueryPages causes all query
199 * pages to be declared expensive. Some query pages are always expensive.
201 * @return bool
203 function isExpensive() {
204 global $wgDisableQueryPages;
205 return $wgDisableQueryPages;
209 * Is the output of this query cacheable? Non-cacheable expensive pages
210 * will be disabled in miser mode and will not have their results written
211 * to the querycache table.
212 * @return bool
213 * @since 1.18
215 public function isCacheable() {
216 return true;
220 * Whether or not the output of the page in question is retrieved from
221 * the database cache.
223 * @return bool
225 function isCached() {
226 global $wgMiserMode;
228 return $this->isExpensive() && $wgMiserMode;
232 * Sometime we don't want to build rss / atom feeds.
234 * @return bool
236 function isSyndicated() {
237 return true;
241 * Formats the results of the query for display. The skin is the current
242 * skin; you can use it for making links. The result is a single row of
243 * result data. You should be able to grab SQL results off of it.
244 * If the function returns false, the line output will be skipped.
245 * @param Skin $skin
246 * @param object $result Result row
247 * @return string|bool String or false to skip
249 abstract function formatResult( $skin, $result );
252 * The content returned by this function will be output before any result
254 * @return string
256 function getPageHeader() {
257 return '';
261 * If using extra form wheely-dealies, return a set of parameters here
262 * as an associative array. They will be encoded and added to the paging
263 * links (prev/next/lengths).
265 * @return array
267 function linkParameters() {
268 return array();
272 * Some special pages (for example SpecialListusers) might not return the
273 * current object formatted, but return the previous one instead.
274 * Setting this to return true will ensure formatResult() is called
275 * one more time to make sure that the very last result is formatted
276 * as well.
277 * @return bool
279 function tryLastResult() {
280 return false;
284 * Clear the cache and save new results
286 * @param int|bool $limit Limit for SQL statement
287 * @param bool $ignoreErrors Whether to ignore database errors
288 * @throws DBError|Exception
289 * @return bool|int
291 function recache( $limit, $ignoreErrors = true ) {
292 if ( !$this->isCacheable() ) {
293 return 0;
296 $fname = get_class( $this ) . '::recache';
297 $dbw = wfGetDB( DB_MASTER );
298 $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) );
299 if ( !$dbw || !$dbr ) {
300 return false;
303 try {
304 # Clear out any old cached data
305 $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
306 # Do query
307 $res = $this->reallyDoQuery( $limit, false );
308 $num = false;
309 if ( $res ) {
310 $num = $res->numRows();
311 # Fetch results
312 $vals = array();
313 while ( $res && $row = $dbr->fetchObject( $res ) ) {
314 if ( isset( $row->value ) ) {
315 if ( $this->usesTimestamps() ) {
316 $value = wfTimestamp( TS_UNIX,
317 $row->value );
318 } else {
319 $value = intval( $row->value ); // @bug 14414
321 } else {
322 $value = 0;
325 $vals[] = array( 'qc_type' => $this->getName(),
326 'qc_namespace' => $row->namespace,
327 'qc_title' => $row->title,
328 'qc_value' => $value );
331 # Save results into the querycache table on the master
332 if ( count( $vals ) ) {
333 $dbw->insert( 'querycache', $vals, __METHOD__ );
335 # Update the querycache_info record for the page
336 $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
337 $dbw->insert( 'querycache_info',
338 array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ),
339 $fname );
341 } catch ( DBError $e ) {
342 if ( !$ignoreErrors ) {
343 throw $e; // report query error
345 $num = false; // set result to false to indicate error
348 return $num;
352 * Run the query and return the result
353 * @param int|bool $limit Numerical limit or false for no limit
354 * @param int|bool $offset Numerical offset or false for no offset
355 * @return ResultWrapper
356 * @since 1.18
358 function reallyDoQuery( $limit, $offset = false ) {
359 $fname = get_class( $this ) . "::reallyDoQuery";
360 $dbr = wfGetDB( DB_SLAVE );
361 $query = $this->getQueryInfo();
362 $order = $this->getOrderFields();
364 if ( $this->sortDescending() ) {
365 foreach ( $order as &$field ) {
366 $field .= ' DESC';
370 if ( is_array( $query ) ) {
371 $tables = isset( $query['tables'] ) ? (array)$query['tables'] : array();
372 $fields = isset( $query['fields'] ) ? (array)$query['fields'] : array();
373 $conds = isset( $query['conds'] ) ? (array)$query['conds'] : array();
374 $options = isset( $query['options'] ) ? (array)$query['options'] : array();
375 $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : array();
377 if ( count( $order ) ) {
378 $options['ORDER BY'] = $order;
381 if ( $limit !== false ) {
382 $options['LIMIT'] = intval( $limit );
385 if ( $offset !== false ) {
386 $options['OFFSET'] = intval( $offset );
389 $res = $dbr->select( $tables, $fields, $conds, $fname,
390 $options, $join_conds
392 } else {
393 // Old-fashioned raw SQL style, deprecated
394 $sql = $this->getSQL();
395 $sql .= ' ORDER BY ' . implode( ', ', $order );
396 $sql = $dbr->limitResult( $sql, $limit, $offset );
397 $res = $dbr->query( $sql, $fname );
400 return $dbr->resultObject( $res );
404 * Somewhat deprecated, you probably want to be using execute()
405 * @param int|bool $offset
406 * @oaram int|bool $limit
407 * @return ResultWrapper
409 function doQuery( $offset = false, $limit = false ) {
410 if ( $this->isCached() && $this->isCacheable() ) {
411 return $this->fetchFromCache( $limit, $offset );
412 } else {
413 return $this->reallyDoQuery( $limit, $offset );
418 * Fetch the query results from the query cache
419 * @param int|bool $limit Numerical limit or false for no limit
420 * @param int|bool $offset Numerical offset or false for no offset
421 * @return ResultWrapper
422 * @since 1.18
424 function fetchFromCache( $limit, $offset = false ) {
425 $dbr = wfGetDB( DB_SLAVE );
426 $options = array();
427 if ( $limit !== false ) {
428 $options['LIMIT'] = intval( $limit );
430 if ( $offset !== false ) {
431 $options['OFFSET'] = intval( $offset );
433 if ( $this->sortDescending() ) {
434 $options['ORDER BY'] = 'qc_value DESC';
435 } else {
436 $options['ORDER BY'] = 'qc_value ASC';
438 $res = $dbr->select( 'querycache', array( 'qc_type',
439 'namespace' => 'qc_namespace',
440 'title' => 'qc_title',
441 'value' => 'qc_value' ),
442 array( 'qc_type' => $this->getName() ),
443 __METHOD__, $options
445 return $dbr->resultObject( $res );
448 public function getCachedTimestamp() {
449 if ( is_null( $this->cachedTimestamp ) ) {
450 $dbr = wfGetDB( DB_SLAVE );
451 $fname = get_class( $this ) . '::getCachedTimestamp';
452 $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
453 array( 'qci_type' => $this->getName() ), $fname );
455 return $this->cachedTimestamp;
459 * This is the actual workhorse. It does everything needed to make a
460 * real, honest-to-gosh query page.
461 * @para $par
462 * @return int
464 function execute( $par ) {
465 global $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
467 $user = $this->getUser();
468 if ( !$this->userCanExecute( $user ) ) {
469 $this->displayRestrictionError();
470 return;
473 $this->setHeaders();
474 $this->outputHeader();
476 $out = $this->getOutput();
478 if ( $this->isCached() && !$this->isCacheable() ) {
479 $out->addWikiMsg( 'querypage-disabled' );
480 return 0;
483 $out->setSyndicated( $this->isSyndicated() );
485 if ( $this->limit == 0 && $this->offset == 0 ) {
486 list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
489 // TODO: Use doQuery()
490 if ( !$this->isCached() ) {
491 # select one extra row for navigation
492 $res = $this->reallyDoQuery( $this->limit + 1, $this->offset );
493 } else {
494 # Get the cached result, select one extra row for navigation
495 $res = $this->fetchFromCache( $this->limit + 1, $this->offset );
496 if ( !$this->listoutput ) {
498 # Fetch the timestamp of this update
499 $ts = $this->getCachedTimestamp();
500 $lang = $this->getLanguage();
501 $maxResults = $lang->formatNum( $wgQueryCacheLimit );
503 if ( $ts ) {
504 $updated = $lang->userTimeAndDate( $ts, $user );
505 $updateddate = $lang->userDate( $ts, $user );
506 $updatedtime = $lang->userTime( $ts, $user );
507 $out->addMeta( 'Data-Cache-Time', $ts );
508 $out->addJsConfigVars( 'dataCacheTime', $ts );
509 $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
510 } else {
511 $out->addWikiMsg( 'perfcached', $maxResults );
514 # If updates on this page have been disabled, let the user know
515 # that the data set won't be refreshed for now
516 if ( is_array( $wgDisableQueryPageUpdate )
517 && in_array( $this->getName(), $wgDisableQueryPageUpdate )
519 $out->wrapWikiMsg(
520 "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
521 'querypage-no-updates'
527 $this->numRows = $res->numRows();
529 $dbr = wfGetDB( DB_SLAVE );
530 $this->preprocessResults( $dbr, $res );
532 $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) );
534 # Top header and navigation
535 if ( $this->shownavigation ) {
536 $out->addHTML( $this->getPageHeader() );
537 if ( $this->numRows > 0 ) {
538 $out->addHTML( $this->msg( 'showingresults' )->numParams(
539 min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
540 $this->offset + 1 )->parseAsBlock() );
541 # Disable the "next" link when we reach the end
542 $paging = $this->getLanguage()->viewPrevNext( $this->getTitle( $par ), $this->offset,
543 $this->limit, $this->linkParameters(), ( $this->numRows <= $this->limit ) );
544 $out->addHTML( '<p>' . $paging . '</p>' );
545 } else {
546 # No results to show, so don't bother with "showing X of Y" etc.
547 # -- just let the user know and give up now
548 $out->addWikiMsg( 'specialpage-empty' );
549 $out->addHTML( Xml::closeElement( 'div' ) );
550 return;
554 # The actual results; specialist subclasses will want to handle this
555 # with more than a straight list, so we hand them the info, plus
556 # an OutputPage, and let them get on with it
557 $this->outputResults( $out,
558 $this->getSkin(),
559 $dbr, # Should use a ResultWrapper for this
560 $res,
561 min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
562 $this->offset );
564 # Repeat the paging links at the bottom
565 if ( $this->shownavigation ) {
566 $out->addHTML( '<p>' . $paging . '</p>' );
569 $out->addHTML( Xml::closeElement( 'div' ) );
571 return min( $this->numRows, $this->limit ); # do not return the one extra row, if exist
575 * Format and output report results using the given information plus
576 * OutputPage
578 * @param OutputPage $out OutputPage to print to
579 * @param Skin $skin User skin to use
580 * @param DatabaseBase $dbr Database (read) connection to use
581 * @param int $res Result pointer
582 * @param int $num Number of available result rows
583 * @param int $offset Paging offset
585 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
586 global $wgContLang;
588 if ( $num > 0 ) {
589 $html = array();
590 if ( !$this->listoutput ) {
591 $html[] = $this->openList( $offset );
594 # $res might contain the whole 1,000 rows, so we read up to
595 # $num [should update this to use a Pager]
596 for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
597 $line = $this->formatResult( $skin, $row );
598 if ( $line ) {
599 $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 )
600 ? ' class="not-patrolled"'
601 : '';
602 $html[] = $this->listoutput
603 ? $line
604 : "<li{$attr}>{$line}</li>\n";
608 # Flush the final result
609 if ( $this->tryLastResult() ) {
610 $row = null;
611 $line = $this->formatResult( $skin, $row );
612 if ( $line ) {
613 $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 )
614 ? ' class="not-patrolled"'
615 : '';
616 $html[] = $this->listoutput
617 ? $line
618 : "<li{$attr}>{$line}</li>\n";
622 if ( !$this->listoutput ) {
623 $html[] = $this->closeList();
626 $html = $this->listoutput
627 ? $wgContLang->listToText( $html )
628 : implode( '', $html );
630 $out->addHTML( $html );
635 * @param $offset
636 * @return string
638 function openList( $offset ) {
639 return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
643 * @return string
645 function closeList() {
646 return "</ol>\n";
650 * Do any necessary preprocessing of the result object.
651 * @param DatabaseBase $db
652 * @param ResultWrapper $res
654 function preprocessResults( $db, $res ) {}
657 * Similar to above, but packaging in a syndicated feed instead of a web page
658 * @param string $class
659 * @param int $limit
660 * @return bool
662 function doFeed( $class = '', $limit = 50 ) {
663 global $wgFeed, $wgFeedClasses, $wgFeedLimit;
665 if ( !$wgFeed ) {
666 $this->getOutput()->addWikiMsg( 'feed-unavailable' );
667 return false;
670 $limit = min( $limit, $wgFeedLimit );
672 if ( isset( $wgFeedClasses[$class] ) ) {
673 $feed = new $wgFeedClasses[$class](
674 $this->feedTitle(),
675 $this->feedDesc(),
676 $this->feedUrl() );
677 $feed->outHeader();
679 $res = $this->reallyDoQuery( $limit, 0 );
680 foreach ( $res as $obj ) {
681 $item = $this->feedResult( $obj );
682 if ( $item ) {
683 $feed->outItem( $item );
687 $feed->outFooter();
688 return true;
689 } else {
690 return false;
695 * Override for custom handling. If the titles/links are ok, just do
696 * feedItemDesc()
697 * @param object $row
698 * @return FeedItem|null
700 function feedResult( $row ) {
701 if ( !isset( $row->title ) ) {
702 return null;
704 $title = Title::makeTitle( intval( $row->namespace ), $row->title );
705 if ( $title ) {
706 $date = isset( $row->timestamp ) ? $row->timestamp : '';
707 $comments = '';
708 if ( $title ) {
709 $talkpage = $title->getTalkPage();
710 $comments = $talkpage->getFullURL();
713 return new FeedItem(
714 $title->getPrefixedText(),
715 $this->feedItemDesc( $row ),
716 $title->getFullURL(),
717 $date,
718 $this->feedItemAuthor( $row ),
719 $comments );
720 } else {
721 return null;
725 function feedItemDesc( $row ) {
726 return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
729 function feedItemAuthor( $row ) {
730 return isset( $row->user_text ) ? $row->user_text : '';
733 function feedTitle() {
734 global $wgLanguageCode, $wgSitename;
735 $desc = $this->getDescription();
736 return "$wgSitename - $desc [$wgLanguageCode]";
739 function feedDesc() {
740 return $this->msg( 'tagline' )->text();
743 function feedUrl() {
744 return $this->getTitle()->getFullURL();
749 * Class definition for a wanted query page like
750 * WantedPages, WantedTemplates, etc
752 abstract class WantedQueryPage extends QueryPage {
753 function isExpensive() {
754 return true;
757 function isSyndicated() {
758 return false;
762 * Cache page existence for performance
763 * @param DatabaseBase $db
764 * @param ResultWrapper $res
766 function preprocessResults( $db, $res ) {
767 if ( !$res->numRows() ) {
768 return;
771 $batch = new LinkBatch;
772 foreach ( $res as $row ) {
773 $batch->add( $row->namespace, $row->title );
775 $batch->execute();
777 // Back to start for display
778 $res->seek( 0 );
782 * Should formatResult() always check page existence, even if
783 * the results are fresh? This is a (hopefully temporary)
784 * kluge for Special:WantedFiles, which may contain false
785 * positives for files that exist e.g. in a shared repo (bug
786 * 6220).
787 * @return bool
789 function forceExistenceCheck() {
790 return false;
794 * Format an individual result
796 * @param Skin $skin Skin to use for UI elements
797 * @param object $result Result row
798 * @return string
800 public function formatResult( $skin, $result ) {
801 $title = Title::makeTitleSafe( $result->namespace, $result->title );
802 if ( $title instanceof Title ) {
803 if ( $this->isCached() || $this->forceExistenceCheck() ) {
804 $pageLink = $title->isKnown()
805 ? '<del>' . Linker::link( $title ) . '</del>'
806 : Linker::link(
807 $title,
808 null,
809 array(),
810 array(),
811 array( 'broken' )
813 } else {
814 $pageLink = Linker::link(
815 $title,
816 null,
817 array(),
818 array(),
819 array( 'broken' )
822 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
823 } else {
824 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
829 * Make a "what links here" link for a given title
831 * @param Title $title Title to make the link for
832 * @param object $result Result row
833 * @return string
835 private function makeWlhLink( $title, $result ) {
836 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
837 $label = $this->msg( 'nlinks' )->numParams( $result->value )->escaped();
838 return Linker::link( $wlh, $label );