jenkins-bot has submitted this change and it was merged.

Change subject: Replace Linker::link() usage with LinkRenderer
......................................................................


Replace Linker::link() usage with LinkRenderer

Bug: T149346
Change-Id: Ie384566617f18ad6c3bf836b39702365d59f714d
---
M includes/actions/CreditsAction.php
M includes/actions/HistoryAction.php
M includes/actions/InfoAction.php
M includes/actions/MarkpatrolledAction.php
M includes/cache/CacheHelper.php
M includes/changetags/ChangeTagsLogItem.php
M includes/logging/BlockLogFormatter.php
M includes/logging/ContentModelLogFormatter.php
M includes/logging/DeleteLogFormatter.php
M includes/logging/LogEventsList.php
10 files changed, 81 insertions(+), 59 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/actions/CreditsAction.php 
b/includes/actions/CreditsAction.php
index 1332ab4..803695a 100644
--- a/includes/actions/CreditsAction.php
+++ b/includes/actions/CreditsAction.php
@@ -23,6 +23,8 @@
  * @author <e...@wikitravel.org>
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @ingroup Actions
  */
@@ -198,14 +200,15 @@
                if ( $this->canShowRealUserName() && !$user->isAnon() ) {
                        $real = $user->getRealName();
                } else {
-                       $real = false;
+                       $real = $user->getName();
                }
 
                $page = $user->isAnon()
                        ? SpecialPage::getTitleFor( 'Contributions', 
$user->getName() )
                        : $user->getUserPage();
 
-               return Linker::link( $page, htmlspecialchars( $real ? $real : 
$user->getName() ) );
+               return MediaWikiServices::getInstance()
+                       ->getLinkRenderer()->makeLink( $page, $real );
        }
 
        /**
@@ -231,9 +234,9 @@
         * @return string HTML link
         */
        protected function othersLink() {
-               return Linker::linkKnown(
+               return 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                        $this->getTitle(),
-                       $this->msg( 'others' )->escaped(),
+                       $this->msg( 'others' )->text(),
                        [],
                        [ 'action' => 'credits' ]
                );
diff --git a/includes/actions/HistoryAction.php 
b/includes/actions/HistoryAction.php
index c1763fa..9573cac 100644
--- a/includes/actions/HistoryAction.php
+++ b/includes/actions/HistoryAction.php
@@ -23,6 +23,8 @@
  * @ingroup Actions
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This class handles printing the history page for an article. In order to
  * be efficient, it uses timestamps rather than offsets for paging, to avoid
@@ -58,9 +60,9 @@
 
        protected function getDescription() {
                // Creation of a subtitle link pointing to [[Special:Log]]
-               return Linker::linkKnown(
+               return 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                        SpecialPage::getTitleFor( 'Log' ),
-                       $this->msg( 'viewpagelogs' )->escaped(),
+                       $this->msg( 'viewpagelogs' )->text(),
                        [],
                        [ 'page' => $this->getTitle()->getPrefixedText() ]
                );
@@ -734,9 +736,9 @@
                                $undoTooltip = $latest
                                        ? [ 'title' => $this->msg( 
'tooltip-undo' )->text() ]
                                        : [];
-                               $undolink = Linker::linkKnown(
+                               $undolink = 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                                        $this->getTitle(),
-                                       $this->msg( 'editundo' )->escaped(),
+                                       $this->msg( 'editundo' )->text(),
                                        $undoTooltip,
                                        [
                                                'action' => 'edit',
@@ -788,16 +790,15 @@
         */
        function revLink( $rev ) {
                $date = $this->getLanguage()->userTimeAndDate( 
$rev->getTimestamp(), $this->getUser() );
-               $date = htmlspecialchars( $date );
                if ( $rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) 
) {
-                       $link = Linker::linkKnown(
+                       $link = 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                                $this->getTitle(),
                                $date,
                                [ 'class' => 'mw-changeslist-date' ],
                                [ 'oldid' => $rev->getId() ]
                        );
                } else {
-                       $link = $date;
+                       $link = htmlspecialchars( $date );
                }
                if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
                        $link = "<span class=\"history-deleted\">$link</span>";
@@ -818,7 +819,7 @@
                if ( $latest || !$rev->userCan( Revision::DELETED_TEXT, 
$this->getUser() ) ) {
                        return $cur;
                } else {
-                       return Linker::linkKnown(
+                       return 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                                $this->getTitle(),
                                $cur,
                                [],
@@ -847,9 +848,10 @@
                        return $last;
                }
 
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                if ( $next === 'unknown' ) {
                        # Next row probably exists but is unknown, use an 
oldid=prev link
-                       return Linker::linkKnown(
+                       return $linkRenderer->makeKnownLink(
                                $this->getTitle(),
                                $last,
                                [],
@@ -868,7 +870,7 @@
                        return $last;
                }
 
-               return Linker::linkKnown(
+               return $linkRenderer->makeKnownLink(
                        $this->getTitle(),
                        $last,
                        [],
diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php
index be3be85..49b9ab7 100644
--- a/includes/actions/InfoAction.php
+++ b/includes/actions/InfoAction.php
@@ -230,11 +230,11 @@
                if ( $title->isRedirect() ) {
                        $pageInfo['header-basic'][] = [
                                $this->msg( 'pageinfo-redirectsto' ),
-                               Linker::link( $this->page->getRedirectTarget() 
) .
+                               $linkRenderer->makeLink( 
$this->page->getRedirectTarget() ) .
                                $this->msg( 'word-separator' )->escaped() .
-                               $this->msg( 'parentheses' )->rawParams( 
Linker::link(
+                               $this->msg( 'parentheses' )->rawParams( 
$linkRenderer->makeLink(
                                        $this->page->getRedirectTarget(),
-                                       $this->msg( 'pageinfo-redirectsto-info' 
)->escaped(),
+                                       $this->msg( 'pageinfo-redirectsto-info' 
)->text(),
                                        [],
                                        [ 'action' => 'info' ]
                                ) )->escaped()
@@ -266,9 +266,9 @@
                ) {
                        // Link to Special:PageLanguage with pre-filled page 
title if user has permissions
                        $titleObj = SpecialPage::getTitleFor( 'PageLanguage', 
$title->getPrefixedText() );
-                       $langDisp = Linker::link(
+                       $langDisp = $linkRenderer->makeLink(
                                $titleObj,
-                               $this->msg( 'pageinfo-language' )->escaped()
+                               $this->msg( 'pageinfo-language' )->text()
                        );
                } else {
                        // Display just the message
@@ -360,9 +360,9 @@
                // Redirects to this page
                $whatLinksHere = SpecialPage::getTitleFor( 'Whatlinkshere', 
$title->getPrefixedText() );
                $pageInfo['header-basic'][] = [
-                       Linker::link(
+                       $linkRenderer->makeLink(
                                $whatLinksHere,
-                               $this->msg( 'pageinfo-redirects-name' 
)->escaped(),
+                               $this->msg( 'pageinfo-redirects-name' )->text(),
                                [],
                                [
                                        'hidelinks' => 1,
@@ -436,7 +436,7 @@
 
                        foreach ( $sources as $sourceTitle ) {
                                $cascadingFrom .= Html::rawElement(
-                                       'li', [], Linker::linkKnown( 
$sourceTitle ) );
+                                       'li', [], $linkRenderer->makeKnownLink( 
$sourceTitle ) );
                        }
 
                        $cascadingFrom = Html::rawElement( 'ul', [], 
$cascadingFrom );
@@ -525,9 +525,9 @@
                        // Date of page creation
                        $pageInfo['header-edits'][] = [
                                $this->msg( 'pageinfo-firsttime' ),
-                               Linker::linkKnown(
+                               $linkRenderer->makeKnownLink(
                                        $title,
-                                       htmlspecialchars( 
$lang->userTimeAndDate( $firstRev->getTimestamp(), $user ) ),
+                                       $lang->userTimeAndDate( 
$firstRev->getTimestamp(), $user ),
                                        [],
                                        [ 'oldid' => $firstRev->getId() ]
                                )
@@ -544,11 +544,9 @@
                        // Date of latest edit
                        $pageInfo['header-edits'][] = [
                                $this->msg( 'pageinfo-lasttime' ),
-                               Linker::linkKnown(
+                               $linkRenderer->makeKnownLink(
                                        $title,
-                                       htmlspecialchars(
-                                               $lang->userTimeAndDate( 
$this->page->getTimestamp(), $user )
-                                       ),
+                                       $lang->userTimeAndDate( 
$this->page->getTimestamp(), $user ),
                                        [],
                                        [ 'oldid' => $this->page->getLatest() ]
                                )
@@ -655,9 +653,9 @@
 
                        if ( !$config->get( 'MiserMode' ) && 
$pageCounts['transclusion']['to'] > 0 ) {
                                if ( $pageCounts['transclusion']['to'] > count( 
$transcludedTargets ) ) {
-                                       $more = Linker::link(
+                                       $more = $linkRenderer->makeLink(
                                                $whatLinksHere,
-                                               $this->msg( 'moredotdotdot' 
)->escaped(),
+                                               $this->msg( 'moredotdotdot' 
)->text(),
                                                [],
                                                [ 'hidelinks' => 1, 
'hideredirs' => 1 ]
                                        );
@@ -836,6 +834,7 @@
                $real_names = [];
                $user_names = [];
                $anon_ips = [];
+               $linkRenderer = MediaWikiServices::getLinkRenderer();
 
                # Sift for real versus user names
                /** @var $user User */
@@ -846,11 +845,11 @@
 
                        $hiddenPrefs = $this->context->getConfig()->get( 
'HiddenPrefs' );
                        if ( $user->getId() == 0 ) {
-                               $anon_ips[] = Linker::link( $page, 
htmlspecialchars( $user->getName() ) );
+                               $anon_ips[] = $linkRenderer->makeLink( $page, 
$user->getName() );
                        } elseif ( !in_array( 'realname', $hiddenPrefs ) && 
$user->getRealName() ) {
-                               $real_names[] = Linker::link( $page, 
htmlspecialchars( $user->getRealName() ) );
+                               $real_names[] = $linkRenderer->makeLink( $page, 
$user->getRealName() );
                        } else {
-                               $user_names[] = Linker::link( $page, 
htmlspecialchars( $user->getName() ) );
+                               $user_names[] = $linkRenderer->makeLink( $page, 
$user->getName() );
                        }
                }
 
diff --git a/includes/actions/MarkpatrolledAction.php 
b/includes/actions/MarkpatrolledAction.php
index 8df6044..611e683 100644
--- a/includes/actions/MarkpatrolledAction.php
+++ b/includes/actions/MarkpatrolledAction.php
@@ -20,6 +20,8 @@
  * @ingroup Actions
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Mark a revision as patrolled on a page
  *
@@ -56,6 +58,7 @@
        protected function preText() {
                $rc = $this->getRecentChange();
                $title = $rc->getTitle();
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
 
                // Based on logentry-patrol-patrol (see PatrolLogFormatter)
                $revId = $rc->getAttribute( 'rc_this_oldid' );
@@ -64,8 +67,8 @@
                        'diff' => $revId,
                        'oldid' => $rc->getAttribute( 'rc_last_oldid' )
                ];
-               $revlink = Linker::link( $title, htmlspecialchars( $revId ), 
[], $query );
-               $pagelink = Linker::link( $title, htmlspecialchars( 
$title->getPrefixedText() ) );
+               $revlink = $linkRenderer->makeLink( $title, $revId, [], $query 
);
+               $pagelink = $linkRenderer->makeLink( $title, 
$title->getPrefixedText() );
 
                return $this->msg( 'confirm-markpatrolled-top' )->params(
                        $title->getPrefixedText(),
diff --git a/includes/cache/CacheHelper.php b/includes/cache/CacheHelper.php
index fb461b7..8c70be2 100644
--- a/includes/cache/CacheHelper.php
+++ b/includes/cache/CacheHelper.php
@@ -82,6 +82,8 @@
        function setExpiry( $cacheExpiry );
 }
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Helper class for caching various elements in a single cache entry.
  *
@@ -217,9 +219,9 @@
                        $subPage = explode( '/', $subPage, 2 );
                        $subPage = count( $subPage ) > 1 ? $subPage[1] : false;
 
-                       $message .= ' ' . Linker::link(
+                       $message .= ' ' . 
MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
                                $context->getTitle( $subPage ),
-                               $context->msg( 'cachedspecial-refresh-now' 
)->escaped(),
+                               $context->msg( 'cachedspecial-refresh-now' 
)->text(),
                                [],
                                $refreshArgs
                        );
diff --git a/includes/changetags/ChangeTagsLogItem.php 
b/includes/changetags/ChangeTagsLogItem.php
index 2dc953c..b78efaf 100644
--- a/includes/changetags/ChangeTagsLogItem.php
+++ b/includes/changetags/ChangeTagsLogItem.php
@@ -19,6 +19,8 @@
  * @ingroup Change tagging
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Item class for a logging table row with its associated change tags.
  * @todo Abstract out a base class for this and RevDelLogItem, similar to the
@@ -70,9 +72,9 @@
                $formatter->setAudience( LogFormatter::FOR_THIS_USER );
 
                // Log link for this page
-               $loglink = Linker::link(
+               $loglink = 
MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
                        SpecialPage::getTitleFor( 'Log' ),
-                       $this->list->msg( 'log' )->escaped(),
+                       $this->list->msg( 'log' )->text(),
                        [],
                        [ 'page' => $title->getPrefixedText() ]
                );
diff --git a/includes/logging/BlockLogFormatter.php 
b/includes/logging/BlockLogFormatter.php
index 21e40ec..c390232 100644
--- a/includes/logging/BlockLogFormatter.php
+++ b/includes/logging/BlockLogFormatter.php
@@ -22,6 +22,8 @@
  * @since 1.25
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This class formats block log entries.
  *
@@ -91,6 +93,7 @@
 
        public function getActionLinks() {
                $subtype = $this->entry->getSubtype();
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // 
Action is hidden
                        || !( $subtype === 'block' || $subtype === 'reblock' )
                        || !$this->context->getUser()->isAllowed( 'block' )
@@ -101,13 +104,13 @@
                // Show unblock/change block link
                $title = $this->entry->getTarget();
                $links = [
-                       Linker::linkKnown(
+                       $linkRenderer->makeKnownLink(
                                SpecialPage::getTitleFor( 'Unblock', 
$title->getDBkey() ),
-                               $this->msg( 'unblocklink' )->escaped()
+                               $this->msg( 'unblocklink' )->text()
                        ),
-                       Linker::linkKnown(
+                       $linkRenderer->makeKnownLink(
                                SpecialPage::getTitleFor( 'Block', 
$title->getDBkey() ),
-                               $this->msg( 'change-blocklink' )->escaped()
+                               $this->msg( 'change-blocklink' )->text()
                        )
                ];
 
diff --git a/includes/logging/ContentModelLogFormatter.php 
b/includes/logging/ContentModelLogFormatter.php
index f130740..861ea30 100644
--- a/includes/logging/ContentModelLogFormatter.php
+++ b/includes/logging/ContentModelLogFormatter.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 class ContentModelLogFormatter extends LogFormatter {
        protected function getMessageParameters() {
                $lang = $this->context->getLanguage();
@@ -18,9 +20,9 @@
                }
 
                $params = $this->extractParameters();
-               $revert = Linker::linkKnown(
+               $revert = 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                        SpecialPage::getTitleFor( 'ChangeContentModel' ),
-                       $this->msg( 'logentry-contentmodel-change-revertlink' 
)->escaped(),
+                       $this->msg( 'logentry-contentmodel-change-revertlink' 
)->text(),
                        [],
                        [
                                'pagetitle' => 
$this->entry->getTarget()->getPrefixedText(),
diff --git a/includes/logging/DeleteLogFormatter.php 
b/includes/logging/DeleteLogFormatter.php
index dc9378f..05973df 100644
--- a/includes/logging/DeleteLogFormatter.php
+++ b/includes/logging/DeleteLogFormatter.php
@@ -23,6 +23,8 @@
  * @since 1.22
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This class formats delete log entries.
  *
@@ -114,6 +116,7 @@
 
        public function getActionLinks() {
                $user = $this->context->getUser();
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                if ( !$user->isAllowed( 'deletedhistory' )
                        || $this->entry->isDeleted( LogPage::DELETED_ACTION )
                ) {
@@ -128,9 +131,9 @@
                                } else {
                                        $message = 'undeleteviewlink';
                                }
-                               $revert = Linker::linkKnown(
+                               $revert = $linkRenderer->makeKnownLink(
                                        SpecialPage::getTitleFor( 'Undelete' ),
-                                       $this->msg( $message )->escaped(),
+                                       $this->msg( $message )->text(),
                                        [],
                                        [ 'target' => 
$this->entry->getTarget()->getPrefixedDBkey() ]
                                );
@@ -156,9 +159,9 @@
                                if ( count( $ids ) == 1 ) {
                                        // Live revision diffs...
                                        if ( $key == 'oldid' || $key == 
'revision' ) {
-                                               $links[] = Linker::linkKnown(
+                                               $links[] = 
$linkRenderer->makeKnownLink(
                                                        
$this->entry->getTarget(),
-                                                       $this->msg( 'diff' 
)->escaped(),
+                                                       $this->msg( 'diff' 
)->text(),
                                                        [],
                                                        [
                                                                'diff' => 
intval( $ids[0] ),
@@ -167,9 +170,9 @@
                                                );
                                                // Deleted revision diffs...
                                        } elseif ( $key == 'artimestamp' || 
$key == 'archive' ) {
-                                               $links[] = Linker::linkKnown(
+                                               $links[] = 
$linkRenderer->makeKnownLink(
                                                        
SpecialPage::getTitleFor( 'Undelete' ),
-                                                       $this->msg( 'diff' 
)->escaped(),
+                                                       $this->msg( 'diff' 
)->text(),
                                                        [],
                                                        [
                                                                'target' => 
$this->entry->getTarget()->getPrefixedDBkey(),
@@ -181,9 +184,9 @@
                                }
 
                                // View/modify link...
-                               $links[] = Linker::linkKnown(
+                               $links[] = $linkRenderer->makeKnownLink(
                                        SpecialPage::getTitleFor( 
'Revisiondelete' ),
-                                       $this->msg( 'revdel-restore' 
)->escaped(),
+                                       $this->msg( 'revdel-restore' )->text(),
                                        [],
                                        [
                                                'target' => 
$this->entry->getTarget()->getPrefixedText(),
@@ -206,9 +209,9 @@
                                        $query = implode( ',', $query );
                                }
                                // Link to each hidden object ID, $params[1] is 
the url param
-                               $revert = Linker::linkKnown(
+                               $revert = $linkRenderer->makeKnownLink(
                                        SpecialPage::getTitleFor( 
'Revisiondelete' ),
-                                       $this->msg( 'revdel-restore' 
)->escaped(),
+                                       $this->msg( 'revdel-restore' )->text(),
                                        [],
                                        [
                                                'target' => 
$this->entry->getTarget()->getPrefixedText(),
diff --git a/includes/logging/LogEventsList.php 
b/includes/logging/LogEventsList.php
index 0cf584b..57a7597 100644
--- a/includes/logging/LogEventsList.php
+++ b/includes/logging/LogEventsList.php
@@ -23,6 +23,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 class LogEventsList extends ContextSource {
        const NO_ACTION_LINK = 1;
        const NO_EXTRA_USER_LINKS = 2;
@@ -142,10 +144,11 @@
         */
        private function getFilterLinks( $filter ) {
                // show/hide links
-               $messages = [ $this->msg( 'show' )->escaped(), $this->msg( 
'hide' )->escaped() ];
+               $messages = [ $this->msg( 'show' )->text(), $this->msg( 'hide' 
)->text() ];
                // Option value -> message mapping
                $links = [];
                $hiddens = ''; // keep track for "go" button
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                foreach ( $filter as $type => $val ) {
                        // Should the below assignment be outside the foreach?
                        // Then it would have to be copied. Not certain what is 
more expensive.
@@ -155,7 +158,7 @@
                        $hideVal = 1 - intval( $val );
                        $query[$queryKey] = $hideVal;
 
-                       $link = Linker::linkKnown(
+                       $link = $linkRenderer->makeKnownLink(
                                $this->getTitle(),
                                $messages[$hideVal],
                                [],
@@ -672,9 +675,9 @@
                                $urlParam = array_merge( $urlParam, 
$extraUrlParams );
                        }
 
-                       $s .= Linker::linkKnown(
+                       $s .= 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
                                SpecialPage::getTitleFor( 'Log' ),
-                               $context->msg( 'log-fulllog' )->escaped(),
+                               $context->msg( 'log-fulllog' )->text(),
                                [],
                                $urlParam
                        );

-- 
To view, visit https://gerrit.wikimedia.org/r/324221
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie384566617f18ad6c3bf836b39702365d59f714d
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Haikalizz <heywhit...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Aklapper <aklap...@wikimedia.org>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Fomafix <foma...@googlemail.com>
Gerrit-Reviewer: Haikalizz <heywhit...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: MtDu <justin.d...@gmail.com>
Gerrit-Reviewer: TTO <at.li...@live.com.au>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to