X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialMostlinked.php;h=fbfaa73831f2dcc7994731e1cc74125a61bfc84d;hb=325e6a1b9d37d239b96caba45a1d18f826c11f8a;hp=019df4937af49cbece50dd61db4baabd51879456;hpb=b96b465f7f22d3ffa7fd6728535aa9aeb511ef8a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialMostlinked.php b/includes/specials/SpecialMostlinked.php index 019df4937a..fbfaa73831 100644 --- a/includes/specials/SpecialMostlinked.php +++ b/includes/specials/SpecialMostlinked.php @@ -25,6 +25,9 @@ * @author Rob Church */ +use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\IDatabase; + /** * A special page to show pages ordered by the number of pages linking to them. * @@ -44,31 +47,31 @@ class MostlinkedPage extends QueryPage { } public function getQueryInfo() { - return array( - 'tables' => array( 'pagelinks', 'page' ), - 'fields' => array( + return [ + 'tables' => [ 'pagelinks', 'page' ], + 'fields' => [ 'namespace' => 'pl_namespace', 'title' => 'pl_title', 'value' => 'COUNT(*)', 'page_namespace' - ), - 'options' => array( + ], + 'options' => [ 'HAVING' => 'COUNT(*) > 1', - 'GROUP BY' => array( + 'GROUP BY' => [ 'pl_namespace', 'pl_title', 'page_namespace' - ) - ), - 'join_conds' => array( - 'page' => array( + ] + ], + 'join_conds' => [ + 'page' => [ 'LEFT JOIN', - array( + [ 'page_namespace = pl_namespace', 'page_title = pl_title' - ) - ) - ) - ); + ] + ] + ] + ]; } /** @@ -78,16 +81,7 @@ class MostlinkedPage extends QueryPage { * @param ResultWrapper $res */ function preprocessResults( $db, $res ) { - if ( $res->numRows() > 0 ) { - $linkBatch = new LinkBatch(); - - foreach ( $res as $row ) { - $linkBatch->add( $row->namespace, $row->title ); - } - - $res->seek( 0 ); - $linkBatch->execute(); - } + $this->executeLBFromResultWrapper( $res ); } /** @@ -100,7 +94,8 @@ class MostlinkedPage extends QueryPage { function makeWlhLink( $title, $caption ) { $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() ); - return Linker::linkKnown( $wlh, $caption ); + $linkRenderer = $this->getLinkRenderer(); + return $linkRenderer->makeKnownLink( $wlh, $caption ); } /** @@ -116,7 +111,7 @@ class MostlinkedPage extends QueryPage { if ( !$title ) { return Html::element( 'span', - array( 'class' => 'mw-invalidtitle' ), + [ 'class' => 'mw-invalidtitle' ], Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, @@ -124,10 +119,11 @@ class MostlinkedPage extends QueryPage { ); } - $link = Linker::link( $title ); + $linkRenderer = $this->getLinkRenderer(); + $link = $linkRenderer->makeLink( $title ); $wlh = $this->makeWlhLink( $title, - $this->msg( 'nlinks' )->numParams( $result->value )->escaped() + $this->msg( 'nlinks' )->numParams( $result->value )->text() ); return $this->getLanguage()->specialList( $link, $wlh );