From 3d6e9faab5ef8d23f04afca836085528d0eaa0e8 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 18 Oct 2012 14:44:47 +0200 Subject: [PATCH] (bBug 41127) Handle non-existent content in WikiPage Change-Id: I8b80a6b7b49b0b8b43eb7d4913860d8ca899015e --- includes/WikiPage.php | 15 ++++++++------- tests/phpunit/includes/WikiPageTest.php | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 9986a8dde7..bdec273134 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -3334,18 +3334,19 @@ 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 ) { - return false; + $content = null; + } else { + #XXX: why use PUBLIC audience here (default), and RAW above? + $content = $rev->getContent(); } + } - #XXX: why use PUBLIC audience here (default), and RAW above? - $content = $rev->getContent(); + if ( $content === null ) { + return false; } $time = - microtime( true ); diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php index fa91452384..e98f5a770c 100644 --- a/tests/phpunit/includes/WikiPageTest.php +++ b/tests/phpunit/includes/WikiPageTest.php @@ -590,14 +590,11 @@ class WikiPageTest extends MediaWikiLangTestCase { return $po; } - /** - * @dataProvider provideGetParserOutput - */ public function testGetParserOutput_nonexisting( ) { static $count = 0; $count ++; - $page = new WikiPage( new Title( "testGetParserOutput_nonexisting_$count" ) ); + $page = new WikiPage( new Title( "WikiPageTest_testGetParserOutput_nonexisting_$count" ) ); $opt = new ParserOptions(); $po = $page->getParserOutput( $opt ); @@ -605,6 +602,17 @@ class WikiPageTest extends MediaWikiLangTestCase { $this->assertFalse( $po, "getParserOutput() shall return false for non-existing pages." ); } + public function testGetParserOutput_badrev( ) { + $page = $this->createPage( 'WikiPageTest_testGetParserOutput', "dummy", CONTENT_MODEL_WIKITEXT ); + + $opt = new ParserOptions(); + $po = $page->getParserOutput( $opt, $page->getLatest() + 1234 ); + + //@todo: would be neat to also test deleted revision + + $this->assertFalse( $po, "getParserOutput() shall return false for non-existing revisions." ); + } + static $sections = "Intro -- 2.20.1