(bBug 41127) Handle non-existent content in WikiPage
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 18 Oct 2012 12:44:47 +0000 (14:44 +0200)
committerReedy <reedy@wikimedia.org>
Thu, 18 Oct 2012 14:13:01 +0000 (15:13 +0100)
Change-Id: I8b80a6b7b49b0b8b43eb7d4913860d8ca899015e

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

index 9986a8d..bdec273 100644 (file)
@@ -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 );
index fa91452..e98f5a7 100644 (file)
@@ -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