[Bug 41030] fix fatal error when rendering non-existing pages
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 15 Oct 2012 12:36:03 +0000 (14:36 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Mon, 15 Oct 2012 12:36:03 +0000 (14:36 +0200)
Change-Id: I68dc34aa7d4c27ea7d0fb9488324d0f899564960

includes/WikiPage.php
tests/phpunit/includes/WikiPageTest.php

index 3deb921..9986a8d 100644 (file)
@@ -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 ) {
index cf9b96b..fa91452 100644 (file)
@@ -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