r83535 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83534‎ | r83535 | r83536 >
Date:18:09, 8 March 2011
Author:mah
Status:reverted (Comments)
Tags:
Comment:
* Followup r76127 and r83521 by adding parsertests and using caseFold
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTests.txt
@@ -8433,7 +8433,27 @@
84348434 </p>
84358435 !! end
84368436
 8437+!! article
 8438+A
 8439+!! text
 8440+A
 8441+!! endarticle
84378442
 8443+!! article
 8444
 8445+!! text
 8446
 8447+!! endarticle
 8448+
 8449+!! test
 8450+Bug#542 Link text shouldn't be duplicated in title attributes
 8451+!! input
 8452+[[A]] [[a]] [[Ä]] [[ä]]
 8453+!! result
 8454+<p><a href="https://www.mediawiki.org/wiki/A">A</a> <a href="https://www.mediawiki.org/wiki/A">a</a> <a href="https://www.mediawiki.org/wiki/%C3%84">Ä</a> <a href="https://www.mediawiki.org/wiki/%C3%84">ä</a>
 8455+</p>
 8456+!! end
 8457+
84388458 TODO:
84398459 more images
84408460 more tables
Index: trunk/phase3/includes/Linker.php
@@ -286,11 +286,14 @@
287287 }
288288
289289 # Get a default title attribute.
 290+ global $wgLang;
290291 $known = in_array( 'known', $options );
291292 if ( $target->getPrefixedText() == '' ) {
292293 # A link like [[#Foo]]. This used to mean an empty title
293294 # attribute, but that's silly. Just don't output a title.
294 - } elseif ( $known && strtolower($linkText) !== strtolower($target->getPrefixedText() ) ) {
 295+ } elseif ( $known &&
 296+ $wgLang->caseFold($linkText) !== $wgLang->caseFold($target->getPrefixedText() ) )
 297+ {
295298 $defaults['title'] = $target->getPrefixedText();
296299 } elseif ( !$known ) {
297300 $defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r87030revert r76127, r76129, and r83535 b/c I'm backing out the fix for bug #542. ...mah19:13, 27 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76127Resolves Bug#542 by removing the link title from in-wiki links where...mah19:06, 5 November 2010
r83521followup r76127 — use language-aware comparison between link text and possi...mah14:38, 8 March 2011

Comments

#Comment by Nikerabbit (talk | contribs)   18:16, 8 March 2011

Still looks wrong. Linker is also used by the parser and that shouldn't depend on $wgLang like this.

#Comment by MarkAHershberger (talk | contribs)   18:27, 8 March 2011

ok, so what how would you suggest?

#Comment by Nikerabbit (talk | contribs)   18:39, 8 March 2011

Hard question actually. Why would the given title text differ in case from the page name?

#Comment by MarkAHershberger (talk | contribs)   18:47, 8 March 2011

a and A both link to the same page and if title text isn't given, it will be "A" without this check.

#Comment by Platonides (talk | contribs)   15:46, 9 March 2011

I would say

if ( Title::capitalize($linkText, $target->getNamespace() ) !== $target->getPrefixedText() )

but that fails for namespaces different than NS_MAIN.

#Comment by Nikerabbit (talk | contribs)   16:26, 9 March 2011

$target->getText() ?

#Comment by Platonides (talk | contribs)   17:07, 9 March 2011

The problem is not $target, but $linkText.

Status & tagging log