API tests to verify basic query functionality (list & props)
[mediawiki.git] / includes / QueryPage.php
bloba01ac68ebbec20fbd65b17169420c0eb1a9665ce
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( 'DisambiguationsPage', 'Disambiguations' ),
39 array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
40 array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
41 array( 'LinkSearchPage', 'LinkSearch' ),
42 array( 'ListredirectsPage', 'Listredirects' ),
43 array( 'LonelyPagesPage', 'Lonelypages' ),
44 array( 'LongPagesPage', 'Longpages' ),
45 array( 'MIMEsearchPage', 'MIMEsearch' ),
46 array( 'MostcategoriesPage', 'Mostcategories' ),
47 array( 'MostimagesPage', 'Mostimages' ),
48 array( 'MostinterwikisPage', 'Mostinterwikis' ),
49 array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
50 array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ),
51 array( 'MostlinkedPage', 'Mostlinked' ),
52 array( 'MostrevisionsPage', 'Mostrevisions' ),
53 array( 'FewestrevisionsPage', 'Fewestrevisions' ),
54 array( 'ShortPagesPage', 'Shortpages' ),
55 array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ),
56 array( 'UncategorizedPagesPage', 'Uncategorizedpages' ),
57 array( 'UncategorizedImagesPage', 'Uncategorizedimages' ),
58 array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ),
59 array( 'UnusedCategoriesPage', 'Unusedcategories' ),
60 array( 'UnusedimagesPage', 'Unusedimages' ),
61 array( 'WantedCategoriesPage', 'Wantedcategories' ),
62 array( 'WantedFilesPage', 'Wantedfiles' ),
63 array( 'WantedPagesPage', 'Wantedpages' ),
64 array( 'WantedTemplatesPage', 'Wantedtemplates' ),
65 array( 'UnwatchedPagesPage', 'Unwatchedpages' ),
66 array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
67 array( 'WithoutInterwikiPage', 'Withoutinterwiki' ),
69 wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
71 global $wgDisableCounters;
72 if ( !$wgDisableCounters )
73 $wgQueryPages[] = array( 'PopularPagesPage', 'Popularpages' );
76 /**
77 * This is a class for doing query pages; since they're almost all the same,
78 * we factor out some of the functionality into a superclass, and let
79 * subclasses derive from it.
80 * @ingroup SpecialPage
82 abstract class QueryPage extends SpecialPage {
83 /**
84 * Whether or not we want plain listoutput rather than an ordered list
86 * @var bool
88 var $listoutput = false;
90 /**
91 * The offset and limit in use, as passed to the query() function
93 * @var integer
95 var $offset = 0;
96 var $limit = 0;
98 /**
99 * The number of rows returned by the query. Reading this variable
100 * only makes sense in functions that are run after the query has been
101 * done, such as preprocessResults() and formatRow().
103 protected $numRows;
105 protected $cachedTimestamp = null;
108 * Wheter to show prev/next links
110 protected $shownavigation = true;
113 * A mutator for $this->listoutput;
115 * @param $bool Boolean
117 function setListoutput( $bool ) {
118 $this->listoutput = $bool;
122 * Subclasses return an SQL query here, formatted as an array with the
123 * following keys:
124 * tables => Table(s) for passing to Database::select()
125 * fields => Field(s) for passing to Database::select(), may be *
126 * conds => WHERE conditions
127 * options => options
128 * join_conds => JOIN conditions
130 * Note that the query itself should return the following three columns:
131 * 'namespace', 'title', and 'value'. 'value' is used for sorting.
133 * These may be stored in the querycache table for expensive queries,
134 * and that cached data will be returned sometimes, so the presence of
135 * extra fields can't be relied upon. The cached 'value' column will be
136 * an integer; non-numeric values are useful only for sorting the
137 * initial query (except if they're timestamps, see usesTimestamps()).
139 * Don't include an ORDER or LIMIT clause, they will be added.
141 * If this function is not overridden or returns something other than
142 * an array, getSQL() will be used instead. This is for backwards
143 * compatibility only and is strongly deprecated.
144 * @return array
145 * @since 1.18
147 function getQueryInfo() {
148 return null;
152 * For back-compat, subclasses may return a raw SQL query here, as a string.
153 * This is stronly deprecated; getQueryInfo() should be overridden instead.
154 * @throws MWException
155 * @return string
157 function getSQL() {
158 /* Implement getQueryInfo() instead */
159 throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor 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 Boolean
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 Boolean
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 Boolean
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 Boolean
225 function isCached() {
226 global $wgMiserMode;
228 return $this->isExpensive() && $wgMiserMode;
232 * Sometime we dont want to build rss / atom feeds.
234 * @return Boolean
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 $result object Result row
247 * @return mixed String or false to skip
249 * @param $skin Skin object
250 * @param $result Object: database row
252 abstract function formatResult( $skin, $result );
255 * The content returned by this function will be output before any result
257 * @return String
259 function getPageHeader() {
260 return '';
264 * If using extra form wheely-dealies, return a set of parameters here
265 * as an associative array. They will be encoded and added to the paging
266 * links (prev/next/lengths).
268 * @return Array
270 function linkParameters() {
271 return array();
275 * Some special pages (for example SpecialListusers) might not return the
276 * current object formatted, but return the previous one instead.
277 * Setting this to return true will ensure formatResult() is called
278 * one more time to make sure that the very last result is formatted
279 * as well.
280 * @return bool
282 function tryLastResult() {
283 return false;
287 * Clear the cache and save new results
289 * @param $limit Integer: limit for SQL statement
290 * @param $ignoreErrors Boolean: whether to ignore database errors
291 * @return bool|int
293 function recache( $limit, $ignoreErrors = true ) {
294 if ( !$this->isCacheable() ) {
295 return 0;
298 $fname = get_class( $this ) . '::recache';
299 $dbw = wfGetDB( DB_MASTER );
300 $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) );
301 if ( !$dbw || !$dbr ) {
302 return false;
305 try {
306 # Clear out any old cached data
307 $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
308 # Do query
309 $res = $this->reallyDoQuery( $limit, false );
310 $num = false;
311 if ( $res ) {
312 $num = $res->numRows();
313 # Fetch results
314 $vals = array();
315 while ( $res && $row = $dbr->fetchObject( $res ) ) {
316 if ( isset( $row->value ) ) {
317 if ( $this->usesTimestamps() ) {
318 $value = wfTimestamp( TS_UNIX,
319 $row->value );
320 } else {
321 $value = intval( $row->value ); // @bug 14414
323 } else {
324 $value = 0;
327 $vals[] = array( 'qc_type' => $this->getName(),
328 'qc_namespace' => $row->namespace,
329 'qc_title' => $row->title,
330 'qc_value' => $value );
333 # Save results into the querycache table on the master
334 if ( count( $vals ) ) {
335 $dbw->insert( 'querycache', $vals, __METHOD__ );
337 # Update the querycache_info record for the page
338 $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
339 $dbw->insert( 'querycache_info',
340 array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ),
341 $fname );
343 } catch ( DBError $e ) {
344 if ( !$ignoreErrors ) {
345 throw $e; // report query error
347 $num = false; // set result to false to indicate error
350 return $num;
354 * Run the query and return the result
355 * @param $limit mixed Numerical limit or false for no limit
356 * @param $offset mixed Numerical offset or false for no offset
357 * @return ResultWrapper
358 * @since 1.18
360 function reallyDoQuery( $limit, $offset = false ) {
361 $fname = get_class( $this ) . "::reallyDoQuery";
362 $dbr = wfGetDB( DB_SLAVE );
363 $query = $this->getQueryInfo();
364 $order = $this->getOrderFields();
365 if ( $this->sortDescending() ) {
366 foreach ( $order as &$field ) {
367 $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();
376 if ( count( $order ) ) {
377 $options['ORDER BY'] = $order;
379 if ( $limit !== false ) {
380 $options['LIMIT'] = intval( $limit );
382 if ( $offset !== false ) {
383 $options['OFFSET'] = intval( $offset );
386 $res = $dbr->select( $tables, $fields, $conds, $fname,
387 $options, $join_conds
389 } else {
390 // Old-fashioned raw SQL style, deprecated
391 $sql = $this->getSQL();
392 $sql .= ' ORDER BY ' . implode( ', ', $order );
393 $sql = $dbr->limitResult( $sql, $limit, $offset );
394 $res = $dbr->query( $sql, $fname );
396 return $dbr->resultObject( $res );
400 * Somewhat deprecated, you probably want to be using execute()
401 * @return ResultWrapper
403 function doQuery( $offset = false, $limit = false ) {
404 if ( $this->isCached() && $this->isCacheable() ) {
405 return $this->fetchFromCache( $limit, $offset );
406 } else {
407 return $this->reallyDoQuery( $limit, $offset );
412 * Fetch the query results from the query cache
413 * @param $limit mixed Numerical limit or false for no limit
414 * @param $offset mixed Numerical offset or false for no offset
415 * @return ResultWrapper
416 * @since 1.18
418 function fetchFromCache( $limit, $offset = false ) {
419 $dbr = wfGetDB( DB_SLAVE );
420 $options = array ();
421 if ( $limit !== false ) {
422 $options['LIMIT'] = intval( $limit );
424 if ( $offset !== false ) {
425 $options['OFFSET'] = intval( $offset );
427 if ( $this->sortDescending() ) {
428 $options['ORDER BY'] = 'qc_value DESC';
429 } else {
430 $options['ORDER BY'] = 'qc_value ASC';
432 $res = $dbr->select( 'querycache', array( 'qc_type',
433 'namespace' => 'qc_namespace',
434 'title' => 'qc_title',
435 'value' => 'qc_value' ),
436 array( 'qc_type' => $this->getName() ),
437 __METHOD__, $options
439 return $dbr->resultObject( $res );
442 public function getCachedTimestamp() {
443 if ( is_null( $this->cachedTimestamp ) ) {
444 $dbr = wfGetDB( DB_SLAVE );
445 $fname = get_class( $this ) . '::getCachedTimestamp';
446 $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
447 array( 'qci_type' => $this->getName() ), $fname );
449 return $this->cachedTimestamp;
453 * This is the actual workhorse. It does everything needed to make a
454 * real, honest-to-gosh query page.
455 * @return int
457 function execute( $par ) {
458 global $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
460 $user = $this->getUser();
461 if ( !$this->userCanExecute( $user ) ) {
462 $this->displayRestrictionError();
463 return;
466 $this->setHeaders();
467 $this->outputHeader();
469 $out = $this->getOutput();
471 if ( $this->isCached() && !$this->isCacheable() ) {
472 $out->addWikiMsg( 'querypage-disabled' );
473 return 0;
476 $out->setSyndicated( $this->isSyndicated() );
478 if ( $this->limit == 0 && $this->offset == 0 ) {
479 list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
482 // TODO: Use doQuery()
483 if ( !$this->isCached() ) {
484 # select one extra row for navigation
485 $res = $this->reallyDoQuery( $this->limit + 1, $this->offset );
486 } else {
487 # Get the cached result, select one extra row for navigation
488 $res = $this->fetchFromCache( $this->limit + 1, $this->offset );
489 if ( !$this->listoutput ) {
491 # Fetch the timestamp of this update
492 $ts = $this->getCachedTimestamp();
493 $lang = $this->getLanguage();
494 $maxResults = $lang->formatNum( $wgQueryCacheLimit );
496 if ( $ts ) {
497 $updated = $lang->userTimeAndDate( $ts, $user );
498 $updateddate = $lang->userDate( $ts, $user );
499 $updatedtime = $lang->userTime( $ts, $user );
500 $out->addMeta( 'Data-Cache-Time', $ts );
501 $out->addJsConfigVars( 'dataCacheTime', $ts );
502 $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
503 } else {
504 $out->addWikiMsg( 'perfcached', $maxResults );
507 # If updates on this page have been disabled, let the user know
508 # that the data set won't be refreshed for now
509 if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) {
510 $out->wrapWikiMsg( "<div class=\"mw-querypage-no-updates\">\n$1\n</div>", 'querypage-no-updates' );
515 $this->numRows = $res->numRows();
517 $dbr = wfGetDB( DB_SLAVE );
518 $this->preprocessResults( $dbr, $res );
520 $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) );
522 # Top header and navigation
523 if ( $this->shownavigation ) {
524 $out->addHTML( $this->getPageHeader() );
525 if ( $this->numRows > 0 ) {
526 $out->addHTML( $this->msg( 'showingresults' )->numParams(
527 min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
528 $this->offset + 1 )->parseAsBlock() );
529 # Disable the "next" link when we reach the end
530 $paging = $this->getLanguage()->viewPrevNext( $this->getTitle( $par ), $this->offset,
531 $this->limit, $this->linkParameters(), ( $this->numRows <= $this->limit ) );
532 $out->addHTML( '<p>' . $paging . '</p>' );
533 } else {
534 # No results to show, so don't bother with "showing X of Y" etc.
535 # -- just let the user know and give up now
536 $out->addWikiMsg( 'specialpage-empty' );
537 $out->addHTML( Xml::closeElement( 'div' ) );
538 return;
542 # The actual results; specialist subclasses will want to handle this
543 # with more than a straight list, so we hand them the info, plus
544 # an OutputPage, and let them get on with it
545 $this->outputResults( $out,
546 $this->getSkin(),
547 $dbr, # Should use a ResultWrapper for this
548 $res,
549 min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
550 $this->offset );
552 # Repeat the paging links at the bottom
553 if ( $this->shownavigation ) {
554 $out->addHTML( '<p>' . $paging . '</p>' );
557 $out->addHTML( Xml::closeElement( 'div' ) );
559 return min( $this->numRows, $this->limit ); # do not return the one extra row, if exist
563 * Format and output report results using the given information plus
564 * OutputPage
566 * @param $out OutputPage to print to
567 * @param $skin Skin: user skin to use
568 * @param $dbr Database (read) connection to use
569 * @param $res Integer: result pointer
570 * @param $num Integer: number of available result rows
571 * @param $offset Integer: paging offset
573 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
574 global $wgContLang;
576 if ( $num > 0 ) {
577 $html = array();
578 if ( !$this->listoutput ) {
579 $html[] = $this->openList( $offset );
582 # $res might contain the whole 1,000 rows, so we read up to
583 # $num [should update this to use a Pager]
584 for ( $i = 0; $i < $num && $row = $dbr->fetchObject( $res ); $i++ ) {
585 $line = $this->formatResult( $skin, $row );
586 if ( $line ) {
587 $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 )
588 ? ' class="not-patrolled"'
589 : '';
590 $html[] = $this->listoutput
591 ? $line
592 : "<li{$attr}>{$line}</li>\n";
596 # Flush the final result
597 if ( $this->tryLastResult() ) {
598 $row = null;
599 $line = $this->formatResult( $skin, $row );
600 if ( $line ) {
601 $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 )
602 ? ' class="not-patrolled"'
603 : '';
604 $html[] = $this->listoutput
605 ? $line
606 : "<li{$attr}>{$line}</li>\n";
610 if ( !$this->listoutput ) {
611 $html[] = $this->closeList();
614 $html = $this->listoutput
615 ? $wgContLang->listToText( $html )
616 : implode( '', $html );
618 $out->addHTML( $html );
623 * @param $offset
624 * @return string
626 function openList( $offset ) {
627 return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
631 * @return string
633 function closeList() {
634 return "</ol>\n";
638 * Do any necessary preprocessing of the result object.
640 function preprocessResults( $db, $res ) {}
643 * Similar to above, but packaging in a syndicated feed instead of a web page
644 * @return bool
646 function doFeed( $class = '', $limit = 50 ) {
647 global $wgFeed, $wgFeedClasses;
649 if ( !$wgFeed ) {
650 $this->getOutput()->addWikiMsg( 'feed-unavailable' );
651 return false;
654 global $wgFeedLimit;
655 if ( $limit > $wgFeedLimit ) {
656 $limit = $wgFeedLimit;
659 if ( isset( $wgFeedClasses[$class] ) ) {
660 $feed = new $wgFeedClasses[$class](
661 $this->feedTitle(),
662 $this->feedDesc(),
663 $this->feedUrl() );
664 $feed->outHeader();
666 $res = $this->reallyDoQuery( $limit, 0 );
667 foreach ( $res as $obj ) {
668 $item = $this->feedResult( $obj );
669 if ( $item ) {
670 $feed->outItem( $item );
674 $feed->outFooter();
675 return true;
676 } else {
677 return false;
682 * Override for custom handling. If the titles/links are ok, just do
683 * feedItemDesc()
684 * @return FeedItem|null
686 function feedResult( $row ) {
687 if ( !isset( $row->title ) ) {
688 return null;
690 $title = Title::makeTitle( intval( $row->namespace ), $row->title );
691 if ( $title ) {
692 $date = isset( $row->timestamp ) ? $row->timestamp : '';
693 $comments = '';
694 if ( $title ) {
695 $talkpage = $title->getTalkPage();
696 $comments = $talkpage->getFullURL();
699 return new FeedItem(
700 $title->getPrefixedText(),
701 $this->feedItemDesc( $row ),
702 $title->getFullURL(),
703 $date,
704 $this->feedItemAuthor( $row ),
705 $comments );
706 } else {
707 return null;
711 function feedItemDesc( $row ) {
712 return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
715 function feedItemAuthor( $row ) {
716 return isset( $row->user_text ) ? $row->user_text : '';
719 function feedTitle() {
720 global $wgLanguageCode, $wgSitename;
721 $desc = $this->getDescription();
722 return "$wgSitename - $desc [$wgLanguageCode]";
725 function feedDesc() {
726 return $this->msg( 'tagline' )->text();
729 function feedUrl() {
730 return $this->getTitle()->getFullURL();
735 * Class definition for a wanted query page like
736 * WantedPages, WantedTemplates, etc
738 abstract class WantedQueryPage extends QueryPage {
740 function isExpensive() {
741 return true;
744 function isSyndicated() {
745 return false;
749 * Cache page existence for performance
751 function preprocessResults( $db, $res ) {
752 if ( !$res->numRows() ) {
753 return;
756 $batch = new LinkBatch;
757 foreach ( $res as $row ) {
758 $batch->add( $row->namespace, $row->title );
760 $batch->execute();
762 // Back to start for display
763 $res->seek( 0 );
767 * Should formatResult() always check page existence, even if
768 * the results are fresh? This is a (hopefully temporary)
769 * kluge for Special:WantedFiles, which may contain false
770 * positives for files that exist e.g. in a shared repo (bug
771 * 6220).
772 * @return bool
774 function forceExistenceCheck() {
775 return false;
779 * Format an individual result
781 * @param $skin Skin to use for UI elements
782 * @param $result Result row
783 * @return string
785 public function formatResult( $skin, $result ) {
786 $title = Title::makeTitleSafe( $result->namespace, $result->title );
787 if ( $title instanceof Title ) {
788 if ( $this->isCached() || $this->forceExistenceCheck() ) {
789 $pageLink = $title->isKnown()
790 ? '<del>' . Linker::link( $title ) . '</del>'
791 : Linker::link(
792 $title,
793 null,
794 array(),
795 array(),
796 array( 'broken' )
798 } else {
799 $pageLink = Linker::link(
800 $title,
801 null,
802 array(),
803 array(),
804 array( 'broken' )
807 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
808 } else {
809 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
814 * Make a "what links here" link for a given title
816 * @param $title Title to make the link for
817 * @param $result Object: result row
818 * @return string
820 private function makeWlhLink( $title, $result ) {
821 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
822 $label = $this->msg( 'nlinks' )->numParams( $result->value )->escaped();
823 return Linker::link( $wlh, $label );