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

Change subject: Replace Linker::link() with LinkRenderer in includes directory
......................................................................


Replace Linker::link() with LinkRenderer in includes directory

* CategoryViewer
* OutputPage
* Preferences

Bug: T149346
Change-Id: I9f9bcd9b461884817e8ceefbc6757c436221e331
---
M includes/CategoryViewer.php
M includes/OutputPage.php
M includes/Preferences.php
3 files changed, 30 insertions(+), 14 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  Florianschmidtwelzow: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php
index b95f274..4c4b8bb 100644
--- a/includes/CategoryViewer.php
+++ b/includes/CategoryViewer.php
@@ -197,7 +197,11 @@
                $link = null;
                Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, 
$html, &$link ] );
                if ( $link === null ) {
-                       $link = Linker::link( $title, $html );
+                       $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
+                       if ( $html !== null ) {
+                               $html = new HtmlArmor( $html );
+                       }
+                       $link = $linkRenderer->makeLink( $title, $html );
                }
                if ( $isRedirect ) {
                        $link = '<span class="redirect-in-category">' . $link . 
'</span>';
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 43d71ab..6070114 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -21,6 +21,7 @@
  */
 
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 use MediaWiki\Session\SessionManager;
 use WrappedString\WrappedString;
 use WrappedString\WrappedStringList;
@@ -1010,8 +1011,9 @@
                if ( $title->isRedirect() ) {
                        $query['redirect'] = 'no';
                }
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                return wfMessage( 'backlinksubtitle' )
-                       ->rawParams( Linker::link( $title, null, [], $query ) );
+                       ->rawParams( $linkRenderer->makeLink( $title, null, [], 
$query ) );
        }
 
        /**
@@ -1269,6 +1271,7 @@
                        'OutputPageMakeCategoryLinks',
                        [ &$this, $categories, &$this->mCategoryLinks ] )
                ) {
+                       $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                        foreach ( $categories as $category => $type ) {
                                // array keys will cast numeric category names 
to ints, so cast back to string
                                $category = (string)$category;
@@ -1283,7 +1286,7 @@
                                }
                                $text = $wgContLang->convertHtml( 
$title->getText() );
                                $this->mCategories[$type][] = $title->getText();
-                               $this->mCategoryLinks[$type][] = Linker::link( 
$title, $text );
+                               $this->mCategoryLinks[$type][] = 
$linkRenderer->makeLink( $title, new HtmlArmor( $text ) );
                        }
                }
        }
@@ -2653,8 +2656,10 @@
         * @param array $options Options array to pass to Linker
         */
        public function addReturnTo( $title, array $query = [], $text = null, 
$options = [] ) {
+               $linkRenderer = MediaWikiServices::getInstance()
+                       ->getLinkRendererFactory()->createFromLegacyOptions( 
$options );
                $link = $this->msg( 'returnto' )->rawParams(
-                       Linker::link( $title, $text, [], $query, $options ) 
)->escaped();
+                       $linkRenderer->makeLink( $title, $text, [], $query ) 
)->escaped();
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
        }
 
diff --git a/includes/Preferences.php b/includes/Preferences.php
index d86b19a..d40e0c1 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -21,6 +21,7 @@
  */
 use MediaWiki\Auth\AuthManager;
 use MediaWiki\Auth\PasswordAuthenticationRequest;
+use MediaWiki\MediaWikiServices;
 
 /**
  * We're now using the HTMLForm object with some customisation to generate the
@@ -253,7 +254,9 @@
                        'section' => 'personal/info',
                ];
 
-               $editCount = Linker::link( SpecialPage::getTitleFor( 
"Contributions", $userName ),
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
+
+               $editCount = $linkRenderer->makeLink( SpecialPage::getTitleFor( 
"Contributions", $userName ),
                        $lang->formatNum( $user->getEditCount() ) );
 
                $defaultPreferences['editcount'] = [
@@ -297,8 +300,8 @@
                if ( $canEditPrivateInfo && 
$authManager->allowsAuthenticationDataChange(
                        new PasswordAuthenticationRequest(), false )->isGood()
                ) {
-                       $link = Linker::link( SpecialPage::getTitleFor( 
'ChangePassword' ),
-                               $context->msg( 'prefs-resetpass' )->escaped(), 
[],
+                       $link = $linkRenderer->makeLink( 
SpecialPage::getTitleFor( 'ChangePassword' ),
+                               $context->msg( 'prefs-resetpass' )->text(), [],
                                [ 'returnto' => SpecialPage::getTitleFor( 
'Preferences' )->getPrefixedText() ] );
 
                        $defaultPreferences['password'] = [
@@ -448,9 +451,9 @@
 
                                $emailAddress = $user->getEmail() ? 
htmlspecialchars( $user->getEmail() ) : '';
                                if ( $canEditPrivateInfo && 
$authManager->allowsPropertyChange( 'emailaddress' ) ) {
-                                       $link = Linker::link(
+                                       $link = $linkRenderer->makeLink(
                                                SpecialPage::getTitleFor( 
'ChangeEmail' ),
-                                               $context->msg( 
$user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(),
+                                               $context->msg( 
$user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->text(),
                                                [],
                                                [ 'returnto' => 
SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ] );
 
@@ -601,14 +604,15 @@
                        $linkTools = [];
                        $userName = $user->getName();
 
+                       $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
                        if ( $allowUserCss ) {
                                $cssPage = Title::makeTitleSafe( NS_USER, 
$userName . '/common.css' );
-                               $linkTools[] = Linker::link( $cssPage, 
$context->msg( 'prefs-custom-css' )->escaped() );
+                               $linkTools[] = $linkRenderer->makeLink( 
$cssPage, $context->msg( 'prefs-custom-css' )->text() );
                        }
 
                        if ( $allowUserJs ) {
                                $jsPage = Title::makeTitleSafe( NS_USER, 
$userName . '/common.js' );
-                               $linkTools[] = Linker::link( $jsPage, 
$context->msg( 'prefs-custom-js' )->escaped() );
+                               $linkTools[] = $linkRenderer->makeLink( 
$jsPage, $context->msg( 'prefs-custom-js' )->text() );
                        }
 
                        $defaultPreferences['commoncssjs'] = [
@@ -1110,6 +1114,8 @@
                $mptitle = Title::newMainPage();
                $previewtext = $context->msg( 'skin-preview' )->escaped();
 
+               $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
+
                # Only show skins that aren't disabled in $wgSkipSkins
                $validSkinNames = Skin::getAllowedSkins();
 
@@ -1145,12 +1151,12 @@
                        # Create links to user CSS/JS pages
                        if ( $allowUserCss ) {
                                $cssPage = Title::makeTitleSafe( NS_USER, 
$user->getName() . '/' . $skinkey . '.css' );
-                               $linkTools[] = Linker::link( $cssPage, 
$context->msg( 'prefs-custom-css' )->escaped() );
+                               $linkTools[] = $linkRenderer->makeLink( 
$cssPage, $context->msg( 'prefs-custom-css' )->text() );
                        }
 
                        if ( $allowUserJs ) {
                                $jsPage = Title::makeTitleSafe( NS_USER, 
$user->getName() . '/' . $skinkey . '.js' );
-                               $linkTools[] = Linker::link( $jsPage, 
$context->msg( 'prefs-custom-js' )->escaped() );
+                               $linkTools[] = $linkRenderer->makeLink( 
$jsPage, $context->msg( 'prefs-custom-js' )->text() );
                        }
 
                        $display = $sn . ' ' . $context->msg( 'parentheses' )
@@ -1624,7 +1630,8 @@
                if ( $this->getModifiedUser()->isAllowed( 'editmyoptions' ) ) {
                        $t = SpecialPage::getTitleFor( 'Preferences', 'reset' );
 
-                       $html .= "\n" . Linker::link( $t, $this->msg( 
'restoreprefs' )->escaped(),
+                       $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
+                       $html .= "\n" . $linkRenderer->makeLink( $t, 
$this->msg( 'restoreprefs' )->text(),
                                Html::buttonAttributes( $attrs, [ 'mw-ui-quiet' 
] ) );
 
                        $html = Xml::tags( 'div', [ 'class' => 
'mw-prefs-buttons' ], $html );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9f9bcd9b461884817e8ceefbc6757c436221e331
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Georggi199 <bmp2...@gmail.com>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: MtDu <justin.d...@gmail.com>
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