r85573 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85572‎ | r85573 | r85574 >
Date:21:11, 6 April 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 27473) Fix regression: bold, italic no longer interfere with linktrail for ca, kaa

Patch to ca, kaa linktrails to exclude multiple apostrophes by Platonides: https://bugzilla.wikimedia.org/attachment.cgi?id=8337

Added parser test cases to confirm that the linktrail apostrophe works on those languages, and to confirm that the bug where a link is surrounded by bold or italics is resolved.

Tweaked Linker::splitTrail() to keep it from permanently caching $wgContLang's linktrail; when we change content languages during a script run as we do with parser tests, that was leaving us stuck forever on English's linktrail.
This may slightly slow down that path, since it'll have to make a couple brief function calls into the Language object and its data cache.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesCa.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesKaa.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTests.txt
@@ -1761,7 +1761,61 @@
17621762 </p>
17631763 !!end
17641764
 1765+!! test
 1766+Internal link with ca linktrail, surrounded by bold apostrophes (bug 27473 primary issue)
 1767+!! options
 1768+language=ca
 1769+!! input
 1770+'''[[Main Page]]'''
 1771+!! result
 1772+<p><b><a href="https://www.mediawiki.org/wiki/Main_Page">Main Page</a></b>
 1773+</p>
 1774+!! end
17651775
 1776+!! test
 1777+Internal link with ca linktrail, surrounded by italic apostrophes (bug 27473 primary issue)
 1778+!! options
 1779+language=ca
 1780+!! input
 1781+''[[Main Page]]''
 1782+!! result
 1783+<p><i><a href="https://www.mediawiki.org/wiki/Main_Page">Main Page</a></i>
 1784+</p>
 1785+!! end
 1786+
 1787+!! test
 1788+Internal link with en linktrail: no apostrophes (bug 27473)
 1789+!! options
 1790+language=en
 1791+!! input
 1792+[[Something]]'nice
 1793+!! result
 1794+<p><a href="https://www.mediawiki.org/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
 1795+</p>
 1796+!! end
 1797+
 1798+!! test
 1799+Internal link with ca linktrail with apostrophes (bug 27473)
 1800+!! options
 1801+language=ca
 1802+!! input
 1803+[[Something]]'nice
 1804+!! result
 1805+<p><a href="https://www.mediawiki.org/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
 1806+</p>
 1807+!! end
 1808+
 1809+!! test
 1810+Internal link with kaa linktrail with apostrophes (bug 27473)
 1811+!! options
 1812+language=kaa
 1813+!! input
 1814+[[Something]]'nice
 1815+!! result
 1816+<p><a href="https://www.mediawiki.org/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
 1817+</p>
 1818+!! end
 1819+
17661820 ###
17671821 ### Interwiki links (see maintenance/interwiki.sql)
17681822 ###
Index: trunk/phase3/includes/Linker.php
@@ -1459,11 +1459,8 @@
14601460 * as a two-element array
14611461 */
14621462 static function splitTrail( $trail ) {
1463 - static $regex = false;
1464 - if ( $regex === false ) {
1465 - global $wgContLang;
1466 - $regex = $wgContLang->linkTrail();
1467 - }
 1463+ global $wgContLang;
 1464+ $regex = $wgContLang->linkTrail();
14681465 $inside = '';
14691466 if ( $trail !== '' ) {
14701467 $m = array();
Index: trunk/phase3/languages/messages/MessagesCa.php
@@ -179,7 +179,7 @@
180180 'DeletedContributions' => array( 'Contribucions esborrades' ),
181181 );
182182
183 -$linkTrail = '/^([a-zàèéíòóúç·ïü\']+)(.*)$/sDu';
 183+$linkTrail = "/^((?:[a-zàèéíòóúç·ïü]|'(?!'))+)(.*)$/sDu";
184184
185185 $messages = array(
186186 # User preference toggles
Index: trunk/phase3/languages/messages/MessagesKaa.php
@@ -148,7 +148,7 @@
149149 'ISO 8601 both' => 'xnY-xnm-xnd"T"xnH:xni:xns',
150150 );
151151
152 -$linkTrail = "/^([a-zı'ʼ’“»]+)(.*)$/sDu";
 152+$linkTrail = "/^((?:[a-zıʼ’“»]|'(?!'))+)(.*)$/sDu";
153153
154154 $messages = array(
155155 # User preference toggles
Index: trunk/phase3/RELEASE-NOTES
@@ -231,6 +231,7 @@
232232 * (bug 28430) Make html and TeX output of <math> always be left-to-right.
233233 * (bug 28306) Fix exposure of suppressed usernames in ForeignDBRepo
234234 * (bug 28372) Fix bogus link to suppressed file versions in ForeignDBRepo
 235+* (bug 27473) Fix regression: bold, italic no longer interfere with linktrail for ca, kaa
235236
236237 === API changes in 1.18 ===
237238 * (bug 26339) Throw warning when truncating an overlarge API result

Comments

#Comment by Platonides (talk | contribs)   21:25, 6 April 2011

Nice.

The usual approach for the static is to add another function to clear the caching, but if accessing the regex is fast enough, it is fine. I don't see why there would be a slowdown there in the current code. It should hit :LocalizationCache:loadedItems.

The added testcases pass. Marking ok.

Status & tagging log