r12982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12981‎ | r12982 | r12983 >
Date:22:56, 8 February 2006
Author:timstarling
Status:old
Tags:
Comment:
Bug 4916: Make localised text (notably the word "line") work with the diff cache. Doing it this way means it will work with the external diff engine as well.
Modified paths:
  • /trunk/phase3/includes/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DifferenceEngine.php
@@ -326,6 +326,7 @@
327327 $difftext = $wgMemc->get( $key );
328328 if ( $difftext ) {
329329 wfIncrStats( 'diff_cache_hit' );
 330+ $difftext = $this->localiseLineNumbers( $difftext );
330331 $difftext .= "\n<!-- diff cache key $key -->\n";
331332 return $difftext;
332333 }
@@ -362,10 +363,25 @@
363364 } else {
364365 wfIncrStats( 'diff_uncacheable' );
365366 }
 367+ // Replace line numbers with the text in the user's language
 368+ $difftext = $this->localiseLineNumbers( $difftext );
366369 return $difftext;
367370 }
368371
369372 /**
 373+ * Replace line numbers with the text in the user's language
 374+ */
 375+ function localiseLineNumbers( $text ) {
 376+ return preg_replace_callback( '/<!--LINE (\d+)-->/',
 377+ array( &$this, 'localiseLineNumbersCb' ), $text );
 378+ }
 379+
 380+ function localiseLineNumbersCb( $matches ) {
 381+ global $wgLang;
 382+ return wfMsg( 'lineno', $wgLang->formatNum( $matches[1] ) );
 383+ }
 384+
 385+ /**
370386 * Add the header to a diff body
371387 */
372388 function addHeader( $diff, $otitle, $ntitle ) {
@@ -1601,11 +1617,8 @@
16021618 }
16031619
16041620 function _block_header( $xbeg, $xlen, $ybeg, $ylen ) {
1605 - $l1 = wfMsg( 'lineno', $xbeg );
1606 - $l2 = wfMsg( 'lineno', $ybeg );
1607 -
1608 - $r = '<tr><td colspan="2" align="left"><strong>'.$l1."</strong></td>\n" .
1609 - '<td colspan="2" align="left"><strong>'.$l2."</strong></td></tr>\n";
 1621+ $r = '<tr><td colspan="2" align="left"><strong><!--LINE '.$xbeg."--></strong></td>\n" .
 1622+ '<td colspan="2" align="left"><strong><!--LINE '.$ybeg."--></strong></td></tr>\n";
16101623 return $r;
16111624 }
16121625

Status & tagging log