jenkins-bot has submitted this change and it was merged.
Change subject: DifferenceEngine cleanup
......................................................................
DifferenceEngine cleanup
* Remove mPrefixes from variables
* Turn a define into class const
Change-Id: I80874627df9dffae596f8f7cb3ca28f19ba1f167
---
M docs/memcached.txt
M includes/Article.php
M includes/diff/DifferenceEngine.php
3 files changed, 198 insertions(+), 186 deletions(-)
Approvals:
Kaldari: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/memcached.txt b/docs/memcached.txt
index 16c5760..e5c597d 100644
--- a/docs/memcached.txt
+++ b/docs/memcached.txt
@@ -105,7 +105,7 @@
expiry: one hour
Difference Engine:
- key: $wgDBname:diff:version:{MW_DIFF_VERSION}:oldid:$old:newid:$new
+ key:
$wgDBname:diff:version:{DifferenceEngine::CACHE_VERSION}:oldid:$old:newid:$new
ex: wikidb:diff:version:1.11a:oldid:1:newid:2
stores: body of a difference
cleared by: nothing
diff --git a/includes/Article.php b/includes/Article.php
index a6afd8e..701dae9 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -812,7 +812,7 @@
$de = $contentHandler->createDifferenceEngine(
$this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
// DifferenceEngine directly fetched the revision:
- $this->mRevIdFetched = $de->mNewid;
+ $this->mRevIdFetched = $de->getNewid();
$de->showDiffPage( $diffOnly );
// Run view updates for the newer revision being diffed (and
shown below the diff if not $diffOnly)
diff --git a/includes/diff/DifferenceEngine.php
b/includes/diff/DifferenceEngine.php
index cf78ce0..28f8889 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -22,45 +22,56 @@
*/
/**
- * Constant to indicate diff cache compatibility.
- * Bump this when changing the diff formatting in a way that
- * fixes important bugs or such to force cached diff views to
- * clear.
- */
-define( 'MW_DIFF_VERSION', '1.11a' );
-
-/**
* @todo document
* @ingroup DifferenceEngine
*/
class DifferenceEngine extends ContextSource {
- public $mOldid;
- public $mNewid;
- private $mOldTags;
- private $mNewTags;
+ /**
+ * Constant to indicate diff cache compatibility.
+ * Bump this when changing the diff formatting in a way that
+ * fixes important bugs or such to force cached diff views to
+ * clear.
+ */
+ const CACHE_VERSION ='1.11a';
+ /**#@+
+ * @private
+ */
+ public $oldId;
+ public $newId;
+ private $oldTags;
+ private $newTags;
/**
* @var Content
*/
- public $mOldContent;
- public $mNewContent;
- protected $mDiffLang;
+ public $oldContent;
+ /**
+ * @var Content
+ */
+ public $newContent;
+ protected $diffLang;
/**
* @var Title
*/
- public $mOldPage;
- public $mNewPage;
+ public $oldPage;
+ /**
+ * @var Title
+ */
+ public $newPage;
/**
* @var Revision
*/
- public $mOldRev;
- public $mNewRev;
- private $mRevisionsIdsLoaded = false; // Have the revisions IDs been
loaded
- public $mRevisionsLoaded = false; // Have the revisions been loaded
- public $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1
or 2?
- public $mCacheHit = false; // Was the diff fetched from cache?
+ public $oldRev;
+ /**
+ * @var Revision
+ */
+ public $newRev;
+ private $revisionsIdsLoaded = false; // Have the revisions IDs been
loaded
+ public $revisionsLoaded = false; // Have the revisions been loaded
+ public $textLoaded = 0; // How many text blobs have been loaded, 0, 1
or 2?
+ public $cacheHit = false; // Was the diff fetched from cache?
/**
* Set this to true to add debug info to the HTML output.
@@ -71,12 +82,13 @@
// If true, line X is not displayed when X is 1, for example to increase
// readability and conserve space with many small diffs.
- protected $mReducedLineNumbers = false;
+ protected $reducedLineNumbers = false;
// Link to action=markpatrolled
- protected $mMarkPatrolledLink = null;
+ protected $markPatrolledLink = null;
protected $unhide = false; # show rev_deleted content if allowed
+ private $refreshCache;
/**#@-*/
/**
@@ -97,9 +109,9 @@
wfDebug( "DifferenceEngine old '$old' new '$new' rcid
'$rcid'\n" );
- $this->mOldid = $old;
- $this->mNewid = $new;
- $this->mRefreshCache = $refreshCache;
+ $this->oldId = $old;
+ $this->newId = $new;
+ $this->refreshCache = $refreshCache;
$this->unhide = $unhide;
}
@@ -107,25 +119,25 @@
* @param $value bool
*/
function setReducedLineNumbers( $value = true ) {
- $this->mReducedLineNumbers = $value;
+ $this->reducedLineNumbers = $value;
}
/**
* @return Language
*/
function getDiffLang() {
- if ( $this->mDiffLang === null ) {
+ if ( $this->diffLang === null ) {
# Default language in which the diff text is written.
- $this->mDiffLang = $this->getTitle()->getPageLanguage();
+ $this->diffLang = $this->getTitle()->getPageLanguage();
}
- return $this->mDiffLang;
+ return $this->diffLang;
}
/**
* @return bool
*/
function wasCacheHit() {
- return $this->mCacheHit;
+ return $this->cacheHit;
}
/**
@@ -133,7 +145,7 @@
*/
function getOldid() {
$this->loadRevisionIds();
- return $this->mOldid;
+ return $this->oldId;
}
/**
@@ -141,7 +153,7 @@
*/
function getNewid() {
$this->loadRevisionIds();
- return $this->mNewid;
+ return $this->newId;
}
/**
@@ -188,15 +200,15 @@
$out = $this->getOutput();
$missing = array();
- if ( $this->mOldRev === null ||
- ( $this->mOldRev && $this->mOldContent === null )
+ if ( $this->oldRev === null ||
+ ( $this->oldRev && $this->oldContent === null )
) {
- $missing[] = $this->deletedIdMarker( $this->mOldid );
+ $missing[] = $this->deletedIdMarker( $this->oldId );
}
- if ( $this->mNewRev === null ||
- ( $this->mNewRev && $this->mNewContent === null )
+ if ( $this->newRev === null ||
+ ( $this->newRev && $this->newContent === null )
) {
- $missing[] = $this->deletedIdMarker( $this->mNewid );
+ $missing[] = $this->deletedIdMarker( $this->newId );
}
$out->setPageTitle( $this->msg( 'errorpagetitle' ) );
@@ -219,10 +231,10 @@
}
$user = $this->getUser();
- $permErrors = $this->mNewPage->getUserPermissionsErrors(
'read', $user );
- if ( $this->mOldPage ) { # mOldPage might not be set, see below.
+ $permErrors = $this->newPage->getUserPermissionsErrors( 'read',
$user );
+ if ( $this->oldPage ) { # oldPage might not be set, see below.
$permErrors = wfMergeErrorArrays( $permErrors,
- $this->mOldPage->getUserPermissionsErrors(
'read', $user ) );
+ $this->oldPage->getUserPermissionsErrors(
'read', $user ) );
}
if ( count( $permErrors ) ) {
wfProfileOut( __METHOD__ );
@@ -243,47 +255,47 @@
# Check if one of the revisions is deleted/suppressed
$deleted = $suppressed = false;
- $allowed = $this->mNewRev->userCan( Revision::DELETED_TEXT,
$user );
+ $allowed = $this->newRev->userCan( Revision::DELETED_TEXT,
$user );
$revisionTools = array();
- # mOldRev is false if the difference engine is called with a
"vague" query for
+ # oldRev is false if the difference engine is called with a
"vague" query for
# a diff between a version V and its previous version V' AND
the version V
# is the first version of that article. In that case, V' does
not exist.
- if ( $this->mOldRev === false ) {
- $out->setPageTitle( $this->msg( 'difference-title',
$this->mNewPage->getPrefixedText() ) );
+ if ( $this->oldRev === false ) {
+ $out->setPageTitle( $this->msg( 'difference-title',
$this->newPage->getPrefixedText() ) );
$samePage = true;
$oldHeader = '';
} else {
- wfRunHooks( 'DiffViewHeader', array( $this,
$this->mOldRev, $this->mNewRev ) );
+ wfRunHooks( 'DiffViewHeader', array( $this,
$this->oldRev, $this->newRev ) );
- if ( $this->mNewPage->equals( $this->mOldPage ) ) {
- $out->setPageTitle( $this->msg(
'difference-title', $this->mNewPage->getPrefixedText() ) );
+ if ( $this->newPage->equals( $this->oldPage ) ) {
+ $out->setPageTitle( $this->msg(
'difference-title', $this->newPage->getPrefixedText() ) );
$samePage = true;
} else {
$out->setPageTitle( $this->msg(
'difference-title-multipage',
- $this->mOldPage->getPrefixedText(),
$this->mNewPage->getPrefixedText() ) );
+ $this->oldPage->getPrefixedText(),
$this->newPage->getPrefixedText() ) );
$out->addSubtitle( $this->msg(
'difference-multipage' ) );
$samePage = false;
}
- if ( $samePage && $this->mNewPage->quickUserCan(
'edit', $user ) ) {
- if ( $this->mNewRev->isCurrent() &&
$this->mNewPage->userCan( 'rollback', $user ) ) {
- $rollbackLink =
Linker::generateRollback( $this->mNewRev, $this->getContext() );
+ if ( $samePage && $this->newPage->quickUserCan( 'edit',
$user ) ) {
+ if ( $this->newRev->isCurrent() &&
$this->newPage->userCan( 'rollback', $user ) ) {
+ $rollbackLink =
Linker::generateRollback( $this->newRev, $this->getContext() );
if ( $rollbackLink ) {
$out->preventClickjacking();
$rollback =
'   ' . $rollbackLink;
}
}
- if ( !$this->mOldRev->isDeleted(
Revision::DELETED_TEXT ) &&
- !$this->mNewRev->isDeleted(
Revision::DELETED_TEXT )
+ if ( !$this->oldRev->isDeleted(
Revision::DELETED_TEXT ) &&
+ !$this->newRev->isDeleted(
Revision::DELETED_TEXT )
) {
$undoLink = Html::element( 'a', array(
- 'href' =>
$this->mNewPage->getLocalURL( array(
+ 'href' =>
$this->newPage->getLocalURL( array(
'action' =>
'edit',
- 'undoafter' =>
$this->mOldid,
- 'undo' =>
$this->mNewid ) ),
+ 'undoafter' =>
$this->oldId,
+ 'undo' =>
$this->newId ) ),
'title' =>
Linker::titleAttrib( 'undo' )
),
$this->msg( 'editundo' )->text()
@@ -293,92 +305,92 @@
}
# Make "previous revision link"
- if ( $samePage && $this->mOldRev->getPrevious() ) {
+ if ( $samePage && $this->oldRev->getPrevious() ) {
$prevlink = Linker::linkKnown(
- $this->mOldPage,
+ $this->oldPage,
$this->msg( 'previousdiff' )->escaped(),
array( 'id' => 'differences-prevlink' ),
- array( 'diff' => 'prev', 'oldid' =>
$this->mOldid ) + $query
+ array( 'diff' => 'prev', 'oldid' =>
$this->oldId ) + $query
);
} else {
$prevlink = ' ';
}
- if ( $this->mOldRev->isMinor() ) {
+ if ( $this->oldRev->isMinor() ) {
$oldminor = ChangesList::flag( 'minor' );
} else {
$oldminor = '';
}
- $ldel = $this->revisionDeleteLink( $this->mOldRev );
- $oldRevisionHeader = $this->getRevisionHeader(
$this->mOldRev, 'complete' );
- $oldChangeTags = ChangeTags::formatSummaryRow(
$this->mOldTags, 'diff' );
+ $ldel = $this->revisionDeleteLink( $this->oldRev );
+ $oldRevisionHeader = $this->getRevisionHeader(
$this->oldRev, 'complete' );
+ $oldChangeTags = ChangeTags::formatSummaryRow(
$this->oldTags, 'diff' );
$oldHeader = '<div id="mw-diff-otitle1"><strong>' .
$oldRevisionHeader . '</strong></div>' .
'<div id="mw-diff-otitle2">' .
- Linker::revUserTools( $this->mOldRev,
!$this->unhide ) . '</div>' .
+ Linker::revUserTools( $this->oldRev,
!$this->unhide ) . '</div>' .
'<div id="mw-diff-otitle3">' . $oldminor .
- Linker::revComment( $this->mOldRev,
!$diffOnly, !$this->unhide ) . $ldel . '</div>' .
+ Linker::revComment( $this->oldRev,
!$diffOnly, !$this->unhide ) . $ldel . '</div>' .
'<div id="mw-diff-otitle5">' .
$oldChangeTags[0] . '</div>' .
'<div id="mw-diff-otitle4">' . $prevlink .
'</div>';
- if ( $this->mOldRev->isDeleted( Revision::DELETED_TEXT
) ) {
+ if ( $this->oldRev->isDeleted( Revision::DELETED_TEXT )
) {
$deleted = true; // old revisions text is hidden
- if ( $this->mOldRev->isDeleted(
Revision::DELETED_RESTRICTED ) ) {
+ if ( $this->oldRev->isDeleted(
Revision::DELETED_RESTRICTED ) ) {
$suppressed = true; // also suppressed
}
}
# Check if this user can see the revisions
- if ( !$this->mOldRev->userCan( Revision::DELETED_TEXT,
$user ) ) {
+ if ( !$this->oldRev->userCan( Revision::DELETED_TEXT,
$user ) ) {
$allowed = false;
}
}
# Make "next revision link"
# Skip next link on the top revision
- if ( $samePage && !$this->mNewRev->isCurrent() ) {
+ if ( $samePage && !$this->newRev->isCurrent() ) {
$nextlink = Linker::linkKnown(
- $this->mNewPage,
+ $this->newPage,
$this->msg( 'nextdiff' )->escaped(),
array( 'id' => 'differences-nextlink' ),
- array( 'diff' => 'next', 'oldid' =>
$this->mNewid ) + $query
+ array( 'diff' => 'next', 'oldid' =>
$this->newId ) + $query
);
} else {
$nextlink = ' ';
}
- if ( $this->mNewRev->isMinor() ) {
+ if ( $this->newRev->isMinor() ) {
$newminor = ChangesList::flag( 'minor' );
} else {
$newminor = '';
}
# Handle RevisionDelete links...
- $rdel = $this->revisionDeleteLink( $this->mNewRev );
+ $rdel = $this->revisionDeleteLink( $this->newRev );
# Allow extensions to define their own revision tools
- wfRunHooks( 'DiffRevisionTools', array( $this->mNewRev,
&$revisionTools ) );
+ wfRunHooks( 'DiffRevisionTools', array( $this->newRev,
&$revisionTools ) );
$formattedRevisionTools = array();
// Put each one in parentheses (poor man's button)
foreach ( $revisionTools as $tool ) {
$formattedRevisionTools[] = $this->msg( 'parentheses'
)->rawParams( $tool )->escaped();
}
- $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev,
'complete' ) .
+ $newRevisionHeader = $this->getRevisionHeader( $this->newRev,
'complete' ) .
' ' . implode( ' ', $formattedRevisionTools );
- $newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags,
'diff' );
+ $newChangeTags = ChangeTags::formatSummaryRow( $this->newTags,
'diff' );
$newHeader = '<div id="mw-diff-ntitle1"><strong>' .
$newRevisionHeader . '</strong></div>' .
- '<div id="mw-diff-ntitle2">' . Linker::revUserTools(
$this->mNewRev, !$this->unhide ) .
+ '<div id="mw-diff-ntitle2">' . Linker::revUserTools(
$this->newRev, !$this->unhide ) .
" $rollback</div>" .
'<div id="mw-diff-ntitle3">' . $newminor .
- Linker::revComment( $this->mNewRev, !$diffOnly,
!$this->unhide ) . $rdel . '</div>' .
+ Linker::revComment( $this->newRev, !$diffOnly,
!$this->unhide ) . $rdel . '</div>' .
'<div id="mw-diff-ntitle5">' . $newChangeTags[0] .
'</div>' .
'<div id="mw-diff-ntitle4">' . $nextlink .
$this->markPatrolledLink() . '</div>';
- if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
+ if ( $this->newRev->isDeleted( Revision::DELETED_TEXT ) ) {
$deleted = true; // new revisions text is hidden
- if ( $this->mNewRev->isDeleted(
Revision::DELETED_RESTRICTED ) ) {
+ if ( $this->newRev->isDeleted(
Revision::DELETED_RESTRICTED ) ) {
$suppressed = true; // also suppressed
}
}
@@ -434,22 +446,22 @@
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
$user = $this->getUser();
- if ( $this->mMarkPatrolledLink === null ) {
+ if ( $this->markPatrolledLink === null ) {
// Prepare a change patrol link, if applicable
if (
// Is patrolling enabled and the user allowed
to?
- $wgUseRCPatrol &&
$this->mNewPage->quickUserCan( 'patrol', $user ) &&
+ $wgUseRCPatrol && $this->newPage->quickUserCan(
'patrol', $user ) &&
// Only do this if the revision isn't more than
6 hours older
// than the Max RC age (6h because the RC might
not be cleaned out regularly)
- RecentChange::isInRCLifespan(
$this->mNewRev->getTimestamp(), 21600 )
+ RecentChange::isInRCLifespan(
$this->newRev->getTimestamp(), 21600 )
) {
// Look for an unpatrolled change corresponding
to this diff
$db = wfGetDB( DB_SLAVE );
$change = RecentChange::newFromConds(
array(
- 'rc_timestamp' =>
$db->timestamp( $this->mNewRev->getTimestamp() ),
- 'rc_this_oldid' =>
$this->mNewid,
+ 'rc_timestamp' =>
$db->timestamp( $this->newRev->getTimestamp() ),
+ 'rc_this_oldid' => $this->newId,
'rc_patrolled' => 0
),
__METHOD__,
@@ -473,8 +485,8 @@
}
$token = $user->getEditToken( $rcid );
- $this->mMarkPatrolledLink = ' <span
class="patrollink">[' . Linker::linkKnown(
- $this->mNewPage,
+ $this->markPatrolledLink = ' <span
class="patrollink">[' . Linker::linkKnown(
+ $this->newPage,
$this->msg(
'markaspatrolleddiff' )->escaped(),
array(),
array(
@@ -484,14 +496,14 @@
)
) . ']</span>';
} else {
- $this->mMarkPatrolledLink = '';
+ $this->markPatrolledLink = '';
}
} else {
- $this->mMarkPatrolledLink = '';
+ $this->markPatrolledLink = '';
}
}
- return $this->mMarkPatrolledLink;
+ return $this->markPatrolledLink;
}
/**
@@ -512,7 +524,7 @@
function renderNewRevision() {
wfProfileIn( __METHOD__ );
$out = $this->getOutput();
- $revHeader = $this->getRevisionHeader( $this->mNewRev );
+ $revHeader = $this->getRevisionHeader( $this->newRev );
# Add "current version as of X" title
$out->addHTML( "<hr class='diff-hr' />
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
@@ -520,47 +532,47 @@
# @codingStandardsIgnoreStart Ignoring long lines.
if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) )
) {
$this->loadNewText();
- $out->setRevisionId( $this->mNewid );
- $out->setRevisionTimestamp(
$this->mNewRev->getTimestamp() );
+ $out->setRevisionId( $this->newId );
+ $out->setRevisionTimestamp(
$this->newRev->getTimestamp() );
$out->setArticleFlag( true );
// NOTE: only needed for B/C: custom rendering of
JS/CSS via hook
- if ( $this->mNewPage->isCssJsSubpage() ||
$this->mNewPage->isCssOrJsPage() ) {
+ if ( $this->newPage->isCssJsSubpage() ||
$this->newPage->isCssOrJsPage() ) {
// Stolen from Article::view --AG 2007-10-11
// Give hooks a chance to customise the output
// @todo standardize this crap into one function
- if ( ContentHandler::runLegacyHooks(
'ShowRawCssJs', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+ if ( ContentHandler::runLegacyHooks(
'ShowRawCssJs', array( $this->newContent, $this->newPage, $out ) ) ) {
// NOTE: deprecated hook, B/C only
// use the content object's own
rendering
- $cnt = $this->mNewRev->getContent();
- $po = $cnt ? $cnt->getParserOutput(
$this->mNewRev->getTitle(), $this->mNewRev->getId() ) : null;
+ $cnt = $this->newRev->getContent();
+ $po = $cnt ? $cnt->getParserOutput(
$this->newRev->getTitle(), $this->newRev->getId() ) : null;
$txt = $po ? $po->getText() : '';
$out->addHTML( $txt );
}
- } elseif ( !wfRunHooks( 'ArticleContentViewCustom',
array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+ } elseif ( !wfRunHooks( 'ArticleContentViewCustom',
array( $this->newContent, $this->newPage, $out ) ) ) {
// Handled by extension
- } elseif ( !ContentHandler::runLegacyHooks(
'ArticleViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+ } elseif ( !ContentHandler::runLegacyHooks(
'ArticleViewCustom', array( $this->newContent, $this->newPage, $out ) ) ) {
// NOTE: deprecated hook, B/C only
// Handled by extension
} else {
// Normal page
- if ( $this->getTitle()->equals( $this->mNewPage
) ) {
+ if ( $this->getTitle()->equals( $this->newPage
) ) {
// If the Title stored in the context
is the same as the one
// of the new revision, we can use its
associated WikiPage
// object.
$wikiPage = $this->getWikiPage();
} else {
// Otherwise we need to create our own
WikiPage object
- $wikiPage = WikiPage::factory(
$this->mNewPage );
+ $wikiPage = WikiPage::factory(
$this->newPage );
}
- $parserOutput = $this->getParserOutput(
$wikiPage, $this->mNewRev );
+ $parserOutput = $this->getParserOutput(
$wikiPage, $this->newRev );
# Also try to load it as a redirect
- $rt = $this->mNewContent ?
$this->mNewContent->getRedirectTarget() : null;
+ $rt = $this->newContent ?
$this->newContent->getRedirectTarget() : null;
if ( $rt ) {
- $article = Article::newFromTitle(
$this->mNewPage, $this->getContext() );
+ $article = Article::newFromTitle(
$this->newPage, $this->getContext() );
$out->addHTML( $article->viewRedirect(
$rt ) );
# WikiPage::getParserOutput() should
not return false, but just in case
@@ -654,36 +666,36 @@
public function getDiffBody() {
global $wgMemc;
wfProfileIn( __METHOD__ );
- $this->mCacheHit = true;
+ $this->cacheHit = true;
// Check if the diff should be hidden from this user
if ( !$this->loadRevisionData() ) {
wfProfileOut( __METHOD__ );
return false;
- } elseif ( $this->mOldRev &&
- !$this->mOldRev->userCan( Revision::DELETED_TEXT,
$this->getUser() )
+ } elseif ( $this->oldRev &&
+ !$this->oldRev->userCan( Revision::DELETED_TEXT,
$this->getUser() )
) {
wfProfileOut( __METHOD__ );
return false;
- } elseif ( $this->mNewRev &&
- !$this->mNewRev->userCan( Revision::DELETED_TEXT,
$this->getUser() )
+ } elseif ( $this->newRev &&
+ !$this->newRev->userCan( Revision::DELETED_TEXT,
$this->getUser() )
) {
wfProfileOut( __METHOD__ );
return false;
}
// Short-circuit
- if ( $this->mOldRev === false || ( $this->mOldRev &&
$this->mNewRev
- && $this->mOldRev->getID() == $this->mNewRev->getID() )
)
+ if ( $this->oldRev === false || ( $this->oldRev && $this->newRev
+ && $this->oldRev->getID() == $this->newRev->getID() ) )
{
wfProfileOut( __METHOD__ );
return '';
}
// Cacheable?
$key = false;
- if ( $this->mOldid && $this->mNewid ) {
+ if ( $this->oldId && $this->newId ) {
$key = $this->getDiffBodyCacheKey();
// Try cache
- if ( !$this->mRefreshCache ) {
+ if ( !$this->refreshCache ) {
$difftext = $wgMemc->get( $key );
if ( $difftext ) {
wfIncrStats( 'diff_cache_hit' );
@@ -694,7 +706,7 @@
}
} // don't try to load but save the result
}
- $this->mCacheHit = false;
+ $this->cacheHit = false;
// Loadtext is permission safe, this just clears out the diff
if ( !$this->loadText() ) {
@@ -702,7 +714,7 @@
return false;
}
- $difftext = $this->generateContentDiffBody( $this->mOldContent,
$this->mNewContent );
+ $difftext = $this->generateContentDiffBody( $this->oldContent,
$this->newContent );
// Save to cache for 7 days
if ( !wfRunHooks( 'AbortDiffCache', array( &$this ) ) ) {
@@ -729,12 +741,12 @@
* @throws MWException
*/
protected function getDiffBodyCacheKey() {
- if ( !$this->mOldid || !$this->mNewid ) {
- throw new MWException( 'mOldid and mNewid must be set
to get diff cache key.' );
+ if ( !$this->oldId || !$this->newId ) {
+ throw new MWException( 'oldId and newId must be set to
get diff cache key.' );
}
- return wfMemcKey( 'diff', 'version', MW_DIFF_VERSION,
- 'oldid', $this->mOldid, 'newid', $this->mNewid );
+ return wfMemcKey( 'diff', 'version', self::CACHE_VERSION,
+ 'oldid', $this->oldId, 'newid', $this->newId );
}
/**
@@ -904,7 +916,7 @@
}
function localiseLineNumbersCb( $matches ) {
- if ( $matches[1] === '1' && $this->mReducedLineNumbers ) {
+ if ( $matches[1] === '1' && $this->reducedLineNumbers ) {
return '';
}
return $this->msg( 'lineno' )->numParams( $matches[1]
)->escaped();
@@ -915,25 +927,25 @@
* @return string
*/
function getMultiNotice() {
- if ( !is_object( $this->mOldRev ) || !is_object( $this->mNewRev
) ) {
+ if ( !is_object( $this->oldRev ) || !is_object( $this->newRev )
) {
return '';
- } elseif ( !$this->mOldPage->equals( $this->mNewPage ) ) {
+ } elseif ( !$this->oldPage->equals( $this->newPage ) ) {
// Comparing two different pages? Count would be
meaningless.
return '';
}
- if ( $this->mOldRev->getTimestamp() >
$this->mNewRev->getTimestamp() ) {
- $oldRev = $this->mNewRev; // flip
- $newRev = $this->mOldRev; // flip
+ if ( $this->oldRev->getTimestamp() >
$this->newRev->getTimestamp() ) {
+ $oldRev = $this->newRev; // flip
+ $newRev = $this->oldRev; // flip
} else { // normal case
- $oldRev = $this->mOldRev;
- $newRev = $this->mNewRev;
+ $oldRev = $this->oldRev;
+ $newRev = $this->newRev;
}
- $nEdits = $this->mNewPage->countRevisionsBetween( $oldRev,
$newRev );
+ $nEdits = $this->newPage->countRevisionsBetween( $oldRev,
$newRev );
if ( $nEdits > 0 ) {
$limit = 100; // use diff-multi-manyusers if too many
users
- $numUsers = $this->mNewPage->countAuthorsBetween(
$oldRev, $newRev, $limit );
+ $numUsers = $this->newPage->countAuthorsBetween(
$oldRev, $newRev, $limit );
return self::intermediateEditsMsg( $nEdits, $numUsers,
$limit );
}
return ''; // nothing
@@ -1086,11 +1098,11 @@
* @since 1.21
*/
function setContent( Content $oldContent, Content $newContent ) {
- $this->mOldContent = $oldContent;
- $this->mNewContent = $newContent;
+ $this->oldContent = $oldContent;
+ $this->newContent = $newContent;
- $this->mTextLoaded = 2;
- $this->mRevisionsLoaded = true;
+ $this->textLoaded = 2;
+ $this->revisionsLoaded = true;
}
/**
@@ -1099,7 +1111,7 @@
* @since 1.19
*/
function setTextLanguage( $lang ) {
- $this->mDiffLang = wfGetLangObj( $lang );
+ $this->diffLang = wfGetLangObj( $lang );
}
/**
@@ -1133,23 +1145,23 @@
* Load revision IDs
*/
private function loadRevisionIds() {
- if ( $this->mRevisionsIdsLoaded ) {
+ if ( $this->revisionsIdsLoaded ) {
return;
}
- $this->mRevisionsIdsLoaded = true;
+ $this->revisionsIdsLoaded = true;
- $old = $this->mOldid;
- $new = $this->mNewid;
+ $old = $this->oldId;
+ $new = $this->newId;
- list( $this->mOldid, $this->mNewid ) = self::mapDiffPrevNext(
$old, $new );
- if ( $new === 'next' && $this->mNewid === false ) {
+ list( $this->oldId, $this->newId ) = self::mapDiffPrevNext(
$old, $new );
+ if ( $new === 'next' && $this->newId === false ) {
# if no result, NewId points to the newest old
revision. The only newer
# revision is cur, which is "0".
- $this->mNewid = 0;
+ $this->newId = 0;
}
- wfRunHooks( 'NewDifferenceEngine', array( $this->getTitle(),
&$this->mOldid, &$this->mNewid, $old, $new ) );
+ wfRunHooks( 'NewDifferenceEngine', array( $this->getTitle(),
&$this->oldId, &$this->newId, $old, $new ) );
}
/**
@@ -1165,74 +1177,74 @@
* @return bool
*/
function loadRevisionData() {
- if ( $this->mRevisionsLoaded ) {
+ if ( $this->revisionsLoaded ) {
return true;
}
// Whether it succeeds or fails, we don't want to try again
- $this->mRevisionsLoaded = true;
+ $this->revisionsLoaded = true;
$this->loadRevisionIds();
// Load the new revision object
- if ( $this->mNewid ) {
- $this->mNewRev = Revision::newFromId( $this->mNewid );
+ if ( $this->newId ) {
+ $this->newRev = Revision::newFromId( $this->newId );
} else {
- $this->mNewRev = Revision::newFromTitle(
+ $this->newRev = Revision::newFromTitle(
$this->getTitle(),
false,
Revision::READ_NORMAL
);
}
- if ( !$this->mNewRev instanceof Revision ) {
+ if ( !$this->newRev instanceof Revision ) {
return false;
}
// Update the new revision ID in case it was 0 (makes life
easier doing UI stuff)
- $this->mNewid = $this->mNewRev->getId();
- $this->mNewPage = $this->mNewRev->getTitle();
+ $this->newId = $this->newRev->getId();
+ $this->newPage = $this->newRev->getTitle();
// Load the old revision object
- $this->mOldRev = false;
- if ( $this->mOldid ) {
- $this->mOldRev = Revision::newFromId( $this->mOldid );
- } elseif ( $this->mOldid === 0 ) {
- $rev = $this->mNewRev->getPrevious();
+ $this->oldRev = false;
+ if ( $this->oldId ) {
+ $this->oldRev = Revision::newFromId( $this->oldId );
+ } elseif ( $this->oldId === 0 ) {
+ $rev = $this->newRev->getPrevious();
if ( $rev ) {
- $this->mOldid = $rev->getId();
- $this->mOldRev = $rev;
+ $this->oldId = $rev->getId();
+ $this->oldRev = $rev;
} else {
// No previous revision; mark to show as
first-version only.
- $this->mOldid = false;
- $this->mOldRev = false;
+ $this->oldId = false;
+ $this->oldRev = false;
}
- } /* elseif ( $this->mOldid === false ) leave mOldRev false; */
+ } /* elseif ( $this->oldId === false ) leave oldRev false; */
- if ( is_null( $this->mOldRev ) ) {
+ if ( is_null( $this->oldRev ) ) {
return false;
}
- if ( $this->mOldRev ) {
- $this->mOldPage = $this->mOldRev->getTitle();
+ if ( $this->oldRev ) {
+ $this->oldPage = $this->oldRev->getTitle();
}
// Load tags information for both revisions
$dbr = wfGetDB( DB_SLAVE );
- if ( $this->mOldid !== false ) {
- $this->mOldTags = $dbr->selectField(
+ if ( $this->oldId !== false ) {
+ $this->oldTags = $dbr->selectField(
'tag_summary',
'ts_tags',
- array( 'ts_rev_id' => $this->mOldid ),
+ array( 'ts_rev_id' => $this->oldId ),
__METHOD__
);
} else {
- $this->mOldTags = false;
+ $this->oldTags = false;
}
- $this->mNewTags = $dbr->selectField(
+ $this->newTags = $dbr->selectField(
'tag_summary',
'ts_tags',
- array( 'ts_rev_id' => $this->mNewid ),
+ array( 'ts_rev_id' => $this->newId ),
__METHOD__
);
@@ -1245,27 +1257,27 @@
* @return bool
*/
function loadText() {
- if ( $this->mTextLoaded == 2 ) {
+ if ( $this->textLoaded == 2 ) {
return true;
}
// Whether it succeeds or fails, we don't want to try again
- $this->mTextLoaded = 2;
+ $this->textLoaded = 2;
if ( !$this->loadRevisionData() ) {
return false;
}
- if ( $this->mOldRev ) {
- $this->mOldContent = $this->mOldRev->getContent(
Revision::FOR_THIS_USER, $this->getUser() );
- if ( $this->mOldContent === null ) {
+ if ( $this->oldRev ) {
+ $this->oldContent = $this->oldRev->getContent(
Revision::FOR_THIS_USER, $this->getUser() );
+ if ( $this->oldContent === null ) {
return false;
}
}
- if ( $this->mNewRev ) {
- $this->mNewContent = $this->mNewRev->getContent(
Revision::FOR_THIS_USER, $this->getUser() );
- if ( $this->mNewContent === null ) {
+ if ( $this->newRev ) {
+ $this->newContent = $this->newRev->getContent(
Revision::FOR_THIS_USER, $this->getUser() );
+ if ( $this->newContent === null ) {
return false;
}
}
@@ -1279,17 +1291,17 @@
* @return bool
*/
function loadNewText() {
- if ( $this->mTextLoaded >= 1 ) {
+ if ( $this->textLoaded >= 1 ) {
return true;
}
- $this->mTextLoaded = 1;
+ $this->textLoaded = 1;
if ( !$this->loadRevisionData() ) {
return false;
}
- $this->mNewContent = $this->mNewRev->getContent(
Revision::FOR_THIS_USER, $this->getUser() );
+ $this->newContent = $this->newRev->getContent(
Revision::FOR_THIS_USER, $this->getUser() );
return true;
}
--
To view, visit https://gerrit.wikimedia.org/r/92668
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I80874627df9dffae596f8f7cb3ca28f19ba1f167
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits