summaryrefslogtreecommitdiff
path: root/includes/diff
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /includes/diff
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'includes/diff')
-rw-r--r--includes/diff/DifferenceEngine.php27
-rw-r--r--includes/diff/TableDiffFormatter.php2
-rw-r--r--includes/diff/UnifiedDiffFormatter.php10
3 files changed, 22 insertions, 17 deletions
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 77bbd36a..c138eec2 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -685,24 +685,20 @@ class DifferenceEngine extends ContextSource {
$this->mCacheHit = true;
// Check if the diff should be hidden from this user
if ( !$this->loadRevisionData() ) {
-
return false;
} elseif ( $this->mOldRev &&
!$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
) {
-
return false;
} elseif ( $this->mNewRev &&
!$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
) {
-
return false;
}
// Short-circuit
if ( $this->mOldRev === false || ( $this->mOldRev && $this->mNewRev
&& $this->mOldRev->getID() == $this->mNewRev->getID() )
) {
-
return '';
}
// Cacheable?
@@ -714,7 +710,7 @@ class DifferenceEngine extends ContextSource {
if ( !$this->mRefreshCache ) {
$difftext = $wgMemc->get( $key );
if ( $difftext ) {
- wfIncrStats( 'diff_cache_hit' );
+ wfIncrStats( 'diff_cache.hit' );
$difftext = $this->localiseLineNumbers( $difftext );
$difftext .= "\n<!-- diff cache key $key -->\n";
@@ -726,7 +722,6 @@ class DifferenceEngine extends ContextSource {
// Loadtext is permission safe, this just clears out the diff
if ( !$this->loadText() ) {
-
return false;
}
@@ -734,12 +729,12 @@ class DifferenceEngine extends ContextSource {
// Save to cache for 7 days
if ( !Hooks::run( 'AbortDiffCache', array( &$this ) ) ) {
- wfIncrStats( 'diff_uncacheable' );
+ wfIncrStats( 'diff_cache.uncacheable' );
} elseif ( $key !== false && $difftext !== false ) {
- wfIncrStats( 'diff_cache_miss' );
+ wfIncrStats( 'diff_cache.miss' );
$wgMemc->set( $key, $difftext, 7 * 86400 );
} else {
- wfIncrStats( 'diff_uncacheable' );
+ wfIncrStats( 'diff_cache.uncacheable' );
}
// Replace line numbers with the text in the user's language
if ( $difftext !== false ) {
@@ -859,12 +854,10 @@ class DifferenceEngine extends ContextSource {
$tempFile1 = fopen( $tempName1, "w" );
if ( !$tempFile1 ) {
-
return false;
}
$tempFile2 = fopen( $tempName2, "w" );
if ( !$tempFile2 ) {
-
return false;
}
fwrite( $tempFile1, $otext );
@@ -1040,7 +1033,7 @@ class DifferenceEngine extends ContextSource {
$key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
$msg = $this->msg( $key )->escaped();
$editLink = $this->msg( 'parentheses' )->rawParams(
- Linker::linkKnown( $title, $msg, array( ), $editQuery ) )->escaped();
+ Linker::linkKnown( $title, $msg, array(), $editQuery ) )->escaped();
$header .= ' ' . Html::rawElement(
'span',
array( 'class' => 'mw-diff-edit' ),
@@ -1077,10 +1070,11 @@ class DifferenceEngine extends ContextSource {
// is often in a different language, mostly the page content language/dir
$tableClass = 'diff diff-contentalign-' . htmlspecialchars( $this->getDiffLang()->alignStart() );
$header = "<table class='$tableClass'>";
+ $userLang = htmlspecialchars( $this->getLanguage()->getHtmlCode() );
if ( !$diff && !$otitle ) {
$header .= "
- <tr style='vertical-align: top;'>
+ <tr style='vertical-align: top;' lang='{$userLang}'>
<td class='diff-ntitle'>{$ntitle}</td>
</tr>";
$multiColspan = 1;
@@ -1099,7 +1093,7 @@ class DifferenceEngine extends ContextSource {
}
if ( $otitle || $ntitle ) {
$header .= "
- <tr style='vertical-align: top;'>
+ <tr style='vertical-align: top;' lang='{$userLang}'>
<td colspan='$colspan' class='diff-otitle'>{$otitle}</td>
<td colspan='$colspan' class='diff-ntitle'>{$ntitle}</td>
</tr>";
@@ -1108,10 +1102,11 @@ class DifferenceEngine extends ContextSource {
if ( $multi != '' ) {
$header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
- "class='diff-multi'>{$multi}</td></tr>";
+ "class='diff-multi' lang='{$userLang}'>{$multi}</td></tr>";
}
if ( $notice != '' ) {
- $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;'>{$notice}</td></tr>";
+ $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
+ "lang='{$userLang}'>{$notice}</td></tr>";
}
return $header . $diff . "</table>";
diff --git a/includes/diff/TableDiffFormatter.php b/includes/diff/TableDiffFormatter.php
index 5d0183ff..83e04a54 100644
--- a/includes/diff/TableDiffFormatter.php
+++ b/includes/diff/TableDiffFormatter.php
@@ -62,7 +62,7 @@ class TableDiffFormatter extends DiffFormatter {
protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
// '<!--LINE \d+ -->' get replaced by a localised line number
// in DifferenceEngine::localiseLineNumbers
- $r = '<tr><td colspan="2" class="diff-lineno" id="L' . $xbeg . '" ><!--LINE ' . $xbeg . "--></td>\n" .
+ $r = '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l' . $xbeg . '" ><!--LINE ' . $xbeg . "--></td>\n" .
'<td colspan="2" class="diff-lineno"><!--LINE ' . $ybeg . "--></td></tr>\n";
return $r;
diff --git a/includes/diff/UnifiedDiffFormatter.php b/includes/diff/UnifiedDiffFormatter.php
index 32a76055..5f3ad3d7 100644
--- a/includes/diff/UnifiedDiffFormatter.php
+++ b/includes/diff/UnifiedDiffFormatter.php
@@ -38,6 +38,16 @@ class UnifiedDiffFormatter extends DiffFormatter {
/**
* @param string[] $lines
+ * @param string $prefix
+ */
+ protected function lines( $lines, $prefix = ' ' ) {
+ foreach ( $lines as $line ) {
+ echo "{$prefix}{$line}\n";
+ }
+ }
+
+ /**
+ * @param string[] $lines
*/
protected function added( $lines ) {
$this->lines( $lines, '+' );