From 0c99ecc6f2bda2ba9b7b74e5d1e248a5ad0b4b9d Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 4 Mar 2011 20:16:35 +0000 Subject: [PATCH] * (bug 27763) Article::getParserOutput() no longer throws a fatal given when an incorrect revision ID is passed --- RELEASE-NOTES | 2 ++ includes/Article.php | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 73cddf87b1..c5ff31984e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -155,6 +155,8 @@ PHP if you have not done so prior to upgrading MediaWiki. double HTML escaped * (bug 27700) The upload protection can now also be set for files that do not exist. +* (bug 27763) Article::getParserOutput() no longer throws a fatal given when an + incorrect revision ID is passed. === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result diff --git a/includes/Article.php b/includes/Article.php index 9512ce1f18..85226be885 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -4560,19 +4560,26 @@ class Article { wfIncrStats( 'pcache_miss_stub' ); } - $parserOutput = false; if ( $useParserCache ) { $parserOutput = ParserCache::singleton()->get( $this, $this->getParserOptions() ); + if ( $parserOutput !== false ) { + return $parserOutput; + } } - if ( $parserOutput === false ) { - // Cache miss; parse and output it. + $text = false; + // Cache miss; parse and output it. + if ( $oldid !== null ) { $rev = Revision::newFromTitle( $this->getTitle(), $oldid ); - - return $this->getOutputFromWikitext( $rev->getText(), $useParserCache ); - } else { - return $parserOutput; + if ( $rev !== null ) { + $text = $rev->getText(); + } } + if ( $text === false ) { + $text = $this->getRawText(); + } + + return $this->getOutputFromWikitext( $text, $useParserCache ); } } -- 2.20.1