$rcid = $wgRequest->getVal( 'rcid' );
$rdfrom = $wgRequest->getVal( 'rdfrom' );
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
+ $purge = $wgRequest->getVal( 'action' ) == 'purge';
$wgOut->setArticleFlag( true );
if ( !is_null( $diff ) ) {
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid );
+ $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage( $diffOnly );
}
} else {
$msg = $wgOut->parse( wfMsg( 'confirm_purge' ) );
- $action = $this->mTitle->escapeLocalURL( 'action=purge' );
+ $action = htmlspecialchars( $_SERVER['REQUEST_URI'] );
$button = htmlspecialchars( wfMsg( 'confirm_purge_button' ) );
$msg = str_replace( '$1',
"<form method=\"post\" action=\"$action\">\n" .
* @param $old Integer: old ID we want to show and diff with.
* @param $new String: either 'prev' or 'next'.
* @param $rcid Integer: ??? FIXME (default 0)
+ * @param $refreshCache boolean If set, refreshes the diff cache
*/
- function DifferenceEngine( $titleObj = null, $old = 0, $new = 0, $rcid = 0 ) {
+ function DifferenceEngine( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false ) {
$this->mTitle = $titleObj;
wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n");
$this->mNewid = intval($new);
}
$this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer
+ $this->mRefreshCache = $refreshCache;
}
function showDiffPage( $diffOnly = false ) {
* Returns false if the diff could not be generated, otherwise returns true
*/
function showDiff( $otitle, $ntitle ) {
- global $wgOut, $wgRequest;
- $diff = $this->getDiff( $otitle, $ntitle, $wgRequest->getVal( 'action' ) == 'purge' );
+ global $wgOut;
+ $diff = $this->getDiff( $otitle, $ntitle );
if ( $diff === false ) {
$wgOut->addWikitext( wfMsg( 'missingarticle', "<nowiki>(fixme, bug)</nowiki>" ) );
return false;
*
* @param Title $otitle Old title
* @param Title $ntitle New title
- * @param bool $skipCache Skip the diff cache for this request?
* @return mixed
*/
- function getDiff( $otitle, $ntitle, $skipCache = false ) {
- $body = $this->getDiffBody( $skipCache );
+ function getDiff( $otitle, $ntitle ) {
+ $body = $this->getDiffBody();
if ( $body === false ) {
return false;
} else {
/**
* Get the diff table body, without header
*
- * @param bool $skipCache Skip cache for this request?
* @return mixed
*/
- function getDiffBody( $skipCache = false ) {
+ function getDiffBody() {
global $wgMemc;
$fname = 'DifferenceEngine::getDiffBody';
wfProfileIn( $fname );
// Cacheable?
$key = false;
- if ( $this->mOldid && $this->mNewid && !$skipCache ) {
- // Try cache
+ if ( $this->mOldid && $this->mNewid ) {
$key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, 'oldid', $this->mOldid, 'newid', $this->mNewid );
- $difftext = $wgMemc->get( $key );
- if ( $difftext ) {
- wfIncrStats( 'diff_cache_hit' );
- $difftext = $this->localiseLineNumbers( $difftext );
- $difftext .= "\n<!-- diff cache key $key -->\n";
- wfProfileOut( $fname );
- return $difftext;
- }
+ // Try cache
+ if ( !$this->mRefreshCache ) {
+ $difftext = $wgMemc->get( $key );
+ if ( $difftext ) {
+ wfIncrStats( 'diff_cache_hit' );
+ $difftext = $this->localiseLineNumbers( $difftext );
+ $difftext .= "\n<!-- diff cache key $key -->\n";
+ wfProfileOut( $fname );
+ return $difftext;
+ }
+ } // don't try to load but save the result
}
#loadtext is permission safe, this just clears out the diff