Index: trunk/phase3/includes/Article.php |
— | — | @@ -645,6 +645,7 @@ |
646 | 646 | $rcid = $wgRequest->getVal( 'rcid' ); |
647 | 647 | $rdfrom = $wgRequest->getVal( 'rdfrom' ); |
648 | 648 | $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
| 649 | + $purge = $wgRequest->getVal( 'action' ) == 'purge'; |
649 | 650 | |
650 | 651 | $wgOut->setArticleFlag( true ); |
651 | 652 | |
— | — | @@ -668,7 +669,7 @@ |
669 | 670 | if ( !is_null( $diff ) ) { |
670 | 671 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
671 | 672 | |
672 | | - $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid ); |
| 673 | + $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge ); |
673 | 674 | // DifferenceEngine directly fetched the revision: |
674 | 675 | $this->mRevIdFetched = $de->mNewid; |
675 | 676 | $de->showDiffPage( $diffOnly ); |
— | — | @@ -960,7 +961,7 @@ |
961 | 962 | } |
962 | 963 | } else { |
963 | 964 | $msg = $wgOut->parse( wfMsg( 'confirm_purge' ) ); |
964 | | - $action = $this->mTitle->escapeLocalURL( 'action=purge' ); |
| 965 | + $action = htmlspecialchars( $_SERVER['REQUEST_URI'] ); |
965 | 966 | $button = htmlspecialchars( wfMsg( 'confirm_purge_button' ) ); |
966 | 967 | $msg = str_replace( '$1', |
967 | 968 | "<form method=\"post\" action=\"$action\">\n" . |
Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -38,8 +38,9 @@ |
39 | 39 | * @param $old Integer: old ID we want to show and diff with. |
40 | 40 | * @param $new String: either 'prev' or 'next'. |
41 | 41 | * @param $rcid Integer: ??? FIXME (default 0) |
| 42 | + * @param $refreshCache boolean If set, refreshes the diff cache |
42 | 43 | */ |
43 | | - function DifferenceEngine( $titleObj = null, $old = 0, $new = 0, $rcid = 0 ) { |
| 44 | + function DifferenceEngine( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false ) { |
44 | 45 | $this->mTitle = $titleObj; |
45 | 46 | wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n"); |
46 | 47 | |
— | — | @@ -68,6 +69,7 @@ |
69 | 70 | $this->mNewid = intval($new); |
70 | 71 | } |
71 | 72 | $this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer |
| 73 | + $this->mRefreshCache = $refreshCache; |
72 | 74 | } |
73 | 75 | |
74 | 76 | function showDiffPage( $diffOnly = false ) { |
— | — | @@ -324,8 +326,8 @@ |
325 | 327 | * Returns false if the diff could not be generated, otherwise returns true |
326 | 328 | */ |
327 | 329 | function showDiff( $otitle, $ntitle ) { |
328 | | - global $wgOut, $wgRequest; |
329 | | - $diff = $this->getDiff( $otitle, $ntitle, $wgRequest->getVal( 'action' ) == 'purge' ); |
| 330 | + global $wgOut; |
| 331 | + $diff = $this->getDiff( $otitle, $ntitle ); |
330 | 332 | if ( $diff === false ) { |
331 | 333 | $wgOut->addWikitext( wfMsg( 'missingarticle', "<nowiki>(fixme, bug)</nowiki>" ) ); |
332 | 334 | return false; |
— | — | @@ -352,11 +354,10 @@ |
353 | 355 | * |
354 | 356 | * @param Title $otitle Old title |
355 | 357 | * @param Title $ntitle New title |
356 | | - * @param bool $skipCache Skip the diff cache for this request? |
357 | 358 | * @return mixed |
358 | 359 | */ |
359 | | - function getDiff( $otitle, $ntitle, $skipCache = false ) { |
360 | | - $body = $this->getDiffBody( $skipCache ); |
| 360 | + function getDiff( $otitle, $ntitle ) { |
| 361 | + $body = $this->getDiffBody(); |
361 | 362 | if ( $body === false ) { |
362 | 363 | return false; |
363 | 364 | } else { |
— | — | @@ -368,27 +369,28 @@ |
369 | 370 | /** |
370 | 371 | * Get the diff table body, without header |
371 | 372 | * |
372 | | - * @param bool $skipCache Skip cache for this request? |
373 | 373 | * @return mixed |
374 | 374 | */ |
375 | | - function getDiffBody( $skipCache = false ) { |
| 375 | + function getDiffBody() { |
376 | 376 | global $wgMemc; |
377 | 377 | $fname = 'DifferenceEngine::getDiffBody'; |
378 | 378 | wfProfileIn( $fname ); |
379 | 379 | |
380 | 380 | // Cacheable? |
381 | 381 | $key = false; |
382 | | - if ( $this->mOldid && $this->mNewid && !$skipCache ) { |
| 382 | + if ( $this->mOldid && $this->mNewid ) { |
| 383 | + $key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, 'oldid', $this->mOldid, 'newid', $this->mNewid ); |
383 | 384 | // Try cache |
384 | | - $key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, 'oldid', $this->mOldid, 'newid', $this->mNewid ); |
385 | | - $difftext = $wgMemc->get( $key ); |
386 | | - if ( $difftext ) { |
387 | | - wfIncrStats( 'diff_cache_hit' ); |
388 | | - $difftext = $this->localiseLineNumbers( $difftext ); |
389 | | - $difftext .= "\n<!-- diff cache key $key -->\n"; |
390 | | - wfProfileOut( $fname ); |
391 | | - return $difftext; |
392 | | - } |
| 385 | + if ( !$this->mRefreshCache ) { |
| 386 | + $difftext = $wgMemc->get( $key ); |
| 387 | + if ( $difftext ) { |
| 388 | + wfIncrStats( 'diff_cache_hit' ); |
| 389 | + $difftext = $this->localiseLineNumbers( $difftext ); |
| 390 | + $difftext .= "\n<!-- diff cache key $key -->\n"; |
| 391 | + wfProfileOut( $fname ); |
| 392 | + return $difftext; |
| 393 | + } |
| 394 | + } // don't try to load but save the result |
393 | 395 | } |
394 | 396 | |
395 | 397 | #loadtext is permission safe, this just clears out the diff |