From: Brion Vibber Date: Tue, 18 Mar 2008 23:07:19 +0000 (+0000) Subject: Revert r32126 -- breaks type-safety by having a bunch of Revision functions which... X-Git-Tag: 1.31.0-rc.0~49006 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=302f32c6feaa86daf1a99786c145505d0a03f7fb;p=lhc%2Fweb%2Fwiklou.git Revert r32126 -- breaks type-safety by having a bunch of Revision functions which are supposed to always return strings return booleans sometimes. Let's not toss in even more scary possibilities, please... predictability is nice! --- diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 1f45dba778..48a8226ed0 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -424,13 +424,7 @@ CONTROL; global $wgMemc; $fname = 'DifferenceEngine::getDiffBody'; wfProfileIn( $fname ); - // Should part of this diff be hidden? - $deleted = false; - if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) { - $deleted = true; - } else if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { - $deleted = true; - } + // Cacheable? $key = false; if ( $this->mOldid && $this->mNewid ) { @@ -439,17 +433,11 @@ CONTROL; if ( !$this->mRefreshCache ) { $difftext = $wgMemc->get( $key ); if ( $difftext ) { - // If this diff should be hidden, kill the cache! - if( $deleted ) { - $wgMemc->delete( $key ); - $difftext = false; - } else { - wfIncrStats( 'diff_cache_hit' ); - $difftext = $this->localiseLineNumbers( $difftext ); - $difftext .= "\n\n"; - wfProfileOut( $fname ); - return $difftext; - } + wfIncrStats( 'diff_cache_hit' ); + $difftext = $this->localiseLineNumbers( $difftext ); + $difftext .= "\n\n"; + wfProfileOut( $fname ); + return $difftext; } } // don't try to load but save the result } @@ -458,13 +446,19 @@ CONTROL; if ( !$this->loadText() ) { wfProfileOut( $fname ); return false; + } else if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) { + return ''; + } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { + return ''; } $difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext ); // Save to cache for 7 days // Only do this for public revs, otherwise an admin can view the diff and a non-admin can nab it! - if ( $deleted ) { + if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) { + wfIncrStats( 'diff_uncacheable' ); + } else if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { wfIncrStats( 'diff_uncacheable' ); } else if ( $key !== false && $difftext !== false ) { wfIncrStats( 'diff_cache_miss' ); diff --git a/includes/Revision.php b/includes/Revision.php index 4d872559d5..05a4a68ade 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -421,7 +421,7 @@ class Revision { */ function getUserText() { if( $this->isDeleted( self::DELETED_USER ) ) { - return false; + return ""; } else { return $this->mUserText; } @@ -441,7 +441,7 @@ class Revision { */ function getComment() { if( $this->isDeleted( self::DELETED_COMMENT ) ) { - return false; + return ""; } else { return $this->mComment; } @@ -476,7 +476,7 @@ class Revision { */ function getText() { if( $this->isDeleted( self::DELETED_TEXT ) ) { - return false; + return ""; } else { return $this->getRawText(); } @@ -500,7 +500,7 @@ class Revision { */ function revText() { if( !$this->userCan( self::DELETED_TEXT ) ) { - return false; + return ""; } else { return $this->getRawText(); }