From 8c9a4d8bbb9585d0111685720433f49fd37ca0c5 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 15 Oct 2012 14:36:03 +0200 Subject: [PATCH] [Bug 41030] fix fatal error when rendering non-existing pages Change-Id: I68dc34aa7d4c27ea7d0fb9488324d0f899564960 --- includes/WikiPage.php | 4 ++++ tests/phpunit/includes/WikiPageTest.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 3deb921436..9986a8dde7 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -3334,6 +3334,10 @@ class PoolWorkArticleView extends PoolCounterWork { } elseif ( $isCurrent ) { #XXX: why use RAW audience here, and PUBLIC (default) below? $content = $this->page->getContent( Revision::RAW ); + if ( $content === null ) { + return false; + } + } else { $rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid ); if ( $rev === null ) { diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php index cf9b96bcd0..fa91452384 100644 --- a/tests/phpunit/includes/WikiPageTest.php +++ b/tests/phpunit/includes/WikiPageTest.php @@ -590,6 +590,21 @@ class WikiPageTest extends MediaWikiLangTestCase { return $po; } + /** + * @dataProvider provideGetParserOutput + */ + public function testGetParserOutput_nonexisting( ) { + static $count = 0; + $count ++; + + $page = new WikiPage( new Title( "testGetParserOutput_nonexisting_$count" ) ); + + $opt = new ParserOptions(); + $po = $page->getParserOutput( $opt ); + + $this->assertFalse( $po, "getParserOutput() shall return false for non-existing pages." ); + } + static $sections = "Intro -- 2.20.1