Fix mw-selflink-fragment on variant fragment links
Should have been part of 1fca3b5b.
The fix to doVariants can be seen in old output linking [[Dуна#Foo]] to
Дуна despite [[Dуна]] being a self-link in the test above.
Bug: T198652
Change-Id: Id38cfc47041492c5cc68b4f8f9566f421c9168bd
This commit is contained in:
parent
867b158c51
commit
c356dfed72
2 changed files with 14 additions and 5 deletions
|
|
@ -244,7 +244,10 @@ class LinkHolderArray {
|
|||
$searchkey = "$ns:$index";
|
||||
$displayTextHtml = $entry['text'];
|
||||
if ( isset( $entry['selflink'] ) ) {
|
||||
$replacePairs[$searchkey] = Linker::makeSelfLinkObj( $title, $displayTextHtml, $query );
|
||||
$replacePairs[$searchkey] = Linker::makeSelfLinkObj(
|
||||
$title, $displayTextHtml, $query, '', '',
|
||||
Sanitizer::escapeIdForLink( $title->getFragment() )
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +363,7 @@ class LinkHolderArray {
|
|||
// Self-link checking for mixed/different variant titles. At this point, we
|
||||
// already know the exact title does not exist, so the link cannot be to a
|
||||
// variant of the current title that exists as a separate page.
|
||||
if ( $variantTitle->equals( $parentTitle ) && !$title->hasFragment() ) {
|
||||
if ( $variantTitle->equals( $parentTitle ) ) {
|
||||
$this->internals[$ns][$index]['selflink'] = true;
|
||||
continue 2;
|
||||
}
|
||||
|
|
@ -422,8 +425,15 @@ class LinkHolderArray {
|
|||
foreach ( $variantMap[$varPdbk] as $key ) {
|
||||
[ $ns, $index ] = explode( ':', $key, 2 );
|
||||
$entry =& $this->internals[(int)$ns][(int)$index];
|
||||
$pdbk = $entry['pdbk'];
|
||||
|
||||
// The selflink we marked above might not have been the first
|
||||
// $textVariants so be sure to skip any entries that have
|
||||
// subsequently been marked.
|
||||
if ( isset( $entry['selflink'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pdbk = $entry['pdbk'];
|
||||
if ( !isset( $classes[$pdbk] ) || $classes[$pdbk] === 'new' ) {
|
||||
// found link in some of the variants, replace the link holder data
|
||||
$entry['title'] = $variantTitle;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,6 @@ title=[[Duna]] language=sr
|
|||
!! end
|
||||
|
||||
## Parsoid isn't adding selflinks on variants yet
|
||||
## FIXME: Legacy parser is inconsistent about applying classes to variant links.
|
||||
!! test
|
||||
Link to a section of a variant of this title should be parsed as mw-selflink-fragment
|
||||
!! options
|
||||
|
|
@ -279,7 +278,7 @@ title=[[Duna]] language=sr
|
|||
!! wikitext
|
||||
[[Dуна]] is a self-link while [[Duna#Foo]] and [[Dуна#Foo]] are mw-selflink-fragments.
|
||||
!! html/php
|
||||
<p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a class="mw-selflink-fragment" href="#Foo">Duna#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are mw-selflink-fragments.
|
||||
<p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a class="mw-selflink-fragment" href="#Foo">Duna#Foo</a> and <a class="mw-selflink-fragment" href="#Foo">Dуна#Foo</a> are mw-selflink-fragments.
|
||||
</p>
|
||||
!! html/parsoid
|
||||
<p><a class="mw-selflink selflink" rel="mw:WikiLink" href="./Дуна" title="Дуна" data-parsoid='{"stx":"simple","a":{"href":"./Дуна","title":"Дуна"},"sa":{"href":"Dуна","title":"Dуна"}}'>Dуна</a> is a self-link while <a rel="mw:WikiLink" href="./Дуна#Foo" title="Дуна" data-parsoid='{"stx":"simple","a":{"href":"./Дуна#Foo","title":"Дуна"},"sa":{"href":"Dunа#Foo","title":"Dunа"}}'>Dunа#Foo</a> and <a rel="mw:WikiLink" href="./Дуна#Foo" title="Дуна" data-parsoid='{"stx":"simple","a":{"href":"./Дуна#Foo","title":"Дуна"},"sa":{"href":"Dуна#Foo","title":"Dуна"}}'>Dуна#Foo</a> are not self-links.</p>
|
||||
|
|
|
|||
Loading…
Reference in a new issue