From 2f23d5378875b517f44d8bda4f5831b896868b9d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 10 Jan 2009 13:41:22 +0000 Subject: [PATCH] * Added getRawText() convenience function to always get the current revision * Fix incorrect usage of getContent() which broke if ?oldid was set --- includes/Article.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 5bd3488993..5d91a432e5 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -228,6 +228,21 @@ class Article { return $this->mContent; } } + + /** + * Get the text of the current revision. No side-effects... + * + * @return Return the text of the current revision + */ + public function getRawText() { + // Check process cache for current revision + if( $this->mContentLoaded && $this->mOldId == 0 ) { + return $this->mContent; + } + $rev = Revision::newFromTitle( $this->mTitle ); + $text = $rev ? $rev->getRawText() : false; + return $text; + } /** * This function returns the text of a section, specified by a number ($section). @@ -1128,7 +1143,7 @@ class Article { if( $this->getID() == 0 ) { $text = false; } else { - $text = $this->getContent(); + $text = $this->getRawText(); } $wgMessageCache->replace( $this->mTitle->getDBkey(), $text ); } @@ -1490,7 +1505,7 @@ class Article { $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed('minoredit'); $bot = $flags & EDIT_FORCE_BOT; - $oldtext = $this->getContent(); + $oldtext = $this->getRawText(); // current revision $oldsize = strlen( $oldtext ); # Provide autosummaries if one is not provided and autosummaries are enabled. @@ -2398,7 +2413,7 @@ class Article { return false; } - $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getContent() ), -1 ); + $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getRawText() ), -1 ); array_push( $wgDeferredUpdateList, $u ); // Bitfields to further suppress the content -- 2.20.1