Phantom42 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/326176 )
Change subject: Fix links problem on Special:Search ...................................................................... Fix links problem on Special:Search Fix bug that most links on Special:Search did not have text rendered Also restore some changes from commit f736c3709a54be33f808e8d12f85707b90763165 where Linker::link() usage was replaced by LinkRenderer This reverts commit 791d5319bff0be23c3ea474a84d42ed788355688 Change-Id: Id25d1b1acd0dcafc47511b2db3782e5d441f3731 --- M includes/specials/SpecialRecentchanges.php M includes/specials/SpecialRevisiondelete.php M includes/specials/SpecialSearch.php M includes/specials/SpecialUncategorizedcategories.php M includes/specials/SpecialUnwatchedpages.php M includes/specials/SpecialWhatlinkshere.php 6 files changed, 78 insertions(+), 25 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/76/326176/1 diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 2a93159..8530eb1 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -665,12 +665,11 @@ } unset( $value ); - $text = htmlspecialchars( $title ); if ( $active ) { - $text = '<strong>' . $text . '</strong>'; + $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' ); } - return Linker::linkKnown( $this->getPageTitle(), $text, [], $params ); + return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [], $params ); } /** diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 8780c56..4b0fa00 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -466,9 +466,9 @@ Xml::closeElement( 'form' ) . "\n"; // Show link to edit the dropdown reasons if ( $this->getUser()->isAllowed( 'editinterface' ) ) { - $link = Linker::linkKnown( + $link = $this->getLinkRenderer()->makeKnownLink( $this->msg( 'revdelete-reason-dropdown' )->inContentLanguage()->getTitle(), - $this->msg( 'revdelete-edit-reasonlist' )->escaped(), + $this->msg( 'revdelete-edit-reasonlist' )->text(), [], [ 'action' => 'edit' ] ); diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 9f83832..727179a 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -499,9 +499,16 @@ } $stParams = array_merge( $params, $this->powerSearchOptions() ); - $suggest = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + $snippet = $textMatches->getSuggestionSnippet() ?: null; + if ( $snippet !== null ) { + $snippet = new HtmlArmor( $snippet ); + } + + $suggest = $linkRenderer->makeKnownLink( $this->getPageTitle(), - $textMatches->getSuggestionSnippet() ?: null, + $snippet, [ 'id' => 'mw-search-DYM-suggestion' ], $stParams ); @@ -535,18 +542,25 @@ } $stParams = array_merge( $params, $this->powerSearchOptions() ); - $rewritten = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + $snippet = $textMatches->getQueryAfterRewriteSnippet() ?: null; + if ( $snippet !== null ) { + $snippet = new HtmlArmor( $snippet ); + } + + $rewritten = $linkRenderer->makeKnownLink( $this->getPageTitle(), - $textMatches->getQueryAfterRewriteSnippet() ?: null, + $snippet, [ 'id' => 'mw-search-DYM-rewritten' ], $stParams ); $stParams['search'] = $term; $stParams['runsuggestion'] = 0; - $original = Linker::linkKnown( + $original = $linkRenderer->makeKnownLink( $this->getPageTitle(), - htmlspecialchars( $term ), + $term, [ 'id' => 'mw-search-DYM-original' ], $stParams ); @@ -766,7 +780,13 @@ Hooks::run( 'ShowSearchHitTitle', [ &$link_t, &$titleSnippet, $result, $terms, $this, &$query ] ); - $link = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + if ( $titleSnippet !== null ) { + $titleSnippet = new HtmlArmor( $titleSnippet ); + } + + $link = $linkRenderer->makeKnownLink( $link_t, $titleSnippet, [ 'data-serp-pos' => $position ], // HTML attributes @@ -800,9 +820,13 @@ $redirectText = null; } + if ( $redirectText !== null ) { + $redirectText = new HtmlArmor( $redirectText ); + } + $redirect = "<span class='searchalttitle'>" . $this->msg( 'search-redirect' )->rawParams( - Linker::linkKnown( $redirectTitle, $redirectText ) )->text() . + $linkRenderer->makeKnownLink( $redirectTitle, $redirectText ) )->text() . "</span>"; } @@ -812,9 +836,13 @@ $sectionText = null; } + if ( $sectionText !== null ) { + $sectionText = new HtmlArmor( $sectionText ); + } + $section = "<span class='searchalttitle'>" . $this->msg( 'search-section' )->rawParams( - Linker::linkKnown( $sectionTitle, $sectionText ) )->text() . + $linkRenderer->makeKnownLink( $sectionTitle, $sectionText ) )->text() . "</span>"; } @@ -971,6 +999,8 @@ return ''; } + $linkRenderer = $this->getLinkRenderer(); + $title = $result->getTitle(); $titleSnippet = $result->getTitleSnippet(); @@ -979,7 +1009,11 @@ $titleSnippet = null; } - $link = Linker::linkKnown( + if ( $titleSnippet !== null ) { + $titleSnippet = new HtmlArmor( $titleSnippet ); + } + + $link = $linkRenderer->makeKnownLink( $title, $titleSnippet ); @@ -993,9 +1027,13 @@ $redirectText = null; } + if ( $redirectText !== null ) { + $redirectText = new HtmlArmor( $redirectText ); + } + $redirect = "<span class='searchalttitle'>" . $this->msg( 'search-redirect' )->rawParams( - Linker::linkKnown( $redirectTitle, $redirectText ) )->text() . + $linkRenderer->makeKnownLink( $redirectTitle, $redirectText ) )->text() . "</span>"; } @@ -1013,7 +1051,7 @@ } // "more results" link (special page stuff could be localized, but we might not know target lang) $searchTitle = Title::newFromText( $title->getInterwiki() . ":Special:Search" ); - $searchLink = Linker::linkKnown( + $searchLink = $linkRenderer->makeKnownLink( $searchTitle, $this->msg( 'search-interwiki-more' )->text(), [], diff --git a/includes/specials/SpecialUncategorizedcategories.php b/includes/specials/SpecialUncategorizedcategories.php index 1cc40a9..86d8f89 100644 --- a/includes/specials/SpecialUncategorizedcategories.php +++ b/includes/specials/SpecialUncategorizedcategories.php @@ -42,6 +42,6 @@ $title = Title::makeTitle( NS_CATEGORY, $result->title ); $text = $title->getText(); - return Linker::linkKnown( $title, htmlspecialchars( $text ) ); + return $this->getLinkRenderer()->makeKnownLink( $title, $text ); } } diff --git a/includes/specials/SpecialUnwatchedpages.php b/includes/specials/SpecialUnwatchedpages.php index ae375b2..96878a3 100644 --- a/includes/specials/SpecialUnwatchedpages.php +++ b/includes/specials/SpecialUnwatchedpages.php @@ -116,10 +116,12 @@ $text = $wgContLang->convert( $nt->getPrefixedText() ); - $plink = Linker::linkKnown( $nt, htmlspecialchars( $text ) ); - $wlink = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + $plink = $linkRenderer->makeKnownLink( $nt, $text ); + $wlink = $linkRenderer->makeKnownLink( $nt, - $this->msg( 'watch' )->escaped(), + $this->msg( 'watch' )->text(), [ 'class' => 'mw-watch-link' ], [ 'action' => 'watch' ] ); diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 1ead290..439b6ab 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -327,7 +327,7 @@ $query = []; } - $link = Linker::linkKnown( + $link = $this->getLinkRenderer()->makeKnownLink( $nt, null, $row->page_is_redirect ? [ 'class' => 'mw-redirect' ] : [], @@ -376,9 +376,15 @@ $title = $this->getPageTitle(); } + $linkRenderer = $this->getLinkRenderer(); + + if ( $text !== null ) { + $text = new HtmlArmor( $text ); + } + // always show a "<- Links" link $links = [ - 'links' => Linker::linkKnown( + 'links' => $linkRenderer->makeKnownLink( $title, $text, [], @@ -393,7 +399,11 @@ // check, if the content model is editable through action=edit ContentHandler::getForTitle( $target )->supportsDirectEditing() ) { - $links['edit'] = Linker::linkKnown( + if ( $editText !== null ) { + $editText = new HtmlArmor( $editText ); + } + + $links['edit'] = $linkRenderer->makeKnownLink( $target, $editText, [], @@ -406,7 +416,11 @@ } function makeSelfLink( $text, $query ) { - return Linker::linkKnown( + if ( $text !== null ) { + $text = new HtmlArmor( $text ); + } + + return $this->getLinkRenderer()->makeKnownLink( $this->selfTitle, $text, [], -- To view, visit https://gerrit.wikimedia.org/r/326176 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id25d1b1acd0dcafc47511b2db3782e5d441f3731 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Phantom42 <nikita...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits