r76956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76955‎ | r76956 | r76957 >
Date:20:34, 18 November 2010
Author:aaron
Status:ok
Tags:
Comment:
getDiffBody() cleanups:
* marked it explicitly public
* cleaned up return types on failure
* broke long lines
Modified paths:
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -607,26 +607,31 @@
608608 /**
609609 * Get the diff table body, without header
610610 *
611 - * @return mixed
 611+ * @return mixed (string/false)
612612 */
613 - function getDiffBody() {
 613+ public function getDiffBody() {
614614 global $wgMemc;
615615 wfProfileIn( __METHOD__ );
616616 $this->mCacheHit = true;
617617 // Check if the diff should be hidden from this user
618 - if ( !$this->loadRevisionData() )
 618+ if ( !$this->loadRevisionData() ) {
 619+ return false;
 620+ } elseif ( $this->mOldRev && !$this->mOldRev->userCan( Revision::DELETED_TEXT ) ) {
 621+ return false;
 622+ } elseif ( $this->mNewRev && !$this->mNewRev->userCan( Revision::DELETED_TEXT ) ) {
 623+ return false;
 624+ }
 625+ // Short-circuit
 626+ if ( $this->mOldRev && $this->mNewRev
 627+ && $this->mOldRev->getID() == $this->mNewRev->getID() )
 628+ {
619629 return '';
620 - if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) {
621 - return '';
622 - } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
623 - return '';
624 - } else if ( $this->mOldRev && $this->mNewRev && $this->mOldRev->getID() == $this->mNewRev->getID() ) {
625 - return '';
626630 }
627631 // Cacheable?
628632 $key = false;
629633 if ( $this->mOldid && $this->mNewid ) {
630 - $key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, 'oldid', $this->mOldid, 'newid', $this->mNewid );
 634+ $key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION,
 635+ 'oldid', $this->mOldid, 'newid', $this->mNewid );
631636 // Try cache
632637 if ( !$this->mRefreshCache ) {
633638 $difftext = $wgMemc->get( $key );
@@ -652,7 +657,7 @@
653658 // Save to cache for 7 days
654659 if ( !wfRunHooks( 'AbortDiffCache', array( &$this ) ) ) {
655660 wfIncrStats( 'diff_uncacheable' );
656 - } else if ( $key !== false && $difftext !== false ) {
 661+ } elseif ( $key !== false && $difftext !== false ) {
657662 wfIncrStats( 'diff_cache_miss' );
658663 $wgMemc->set( $key, $difftext, 7*86400 );
659664 } else {

Status & tagging log