From 9107a2d0dd594c5258d7fd8f9617be3f491e9c5d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 18 Mar 2008 23:36:24 +0000 Subject: [PATCH] Check permissions before using cache (bug 9432) --- includes/DifferenceEngine.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 48a8226ed0..83409a60fa 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -424,7 +424,12 @@ CONTROL; global $wgMemc; $fname = 'DifferenceEngine::getDiffBody'; wfProfileIn( $fname ); - + // Check if the diff should be hidden from this user + if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) { + return false; + } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { + return false; + } // Cacheable? $key = false; if ( $this->mOldid && $this->mNewid ) { @@ -446,21 +451,12 @@ 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 ( $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 ) { + if ( $key !== false && $difftext !== false ) { wfIncrStats( 'diff_cache_miss' ); $wgMemc->set( $key, $difftext, 7*86400 ); } else { -- 2.20.1