allow getParserOutput to be overwritten in DifferenceEngine
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 25 Jun 2012 11:44:32 +0000 (13:44 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Mon, 25 Jun 2012 11:44:32 +0000 (13:44 +0200)
Change-Id: I66fbd42c2ada05d5891f2738139b80c0090ecb1b

includes/diff/DifferenceEngine.php

index fc95e8d..178e7f2 100644 (file)
@@ -527,15 +527,7 @@ class DifferenceEngine extends ContextSource {
                                        $wikiPage = WikiPage::factory( $this->mNewPage );
                                }
 
-                               $parserOptions = ParserOptions::newFromContext( $this->getContext() );
-                               $parserOptions->enableLimitReport();
-                               $parserOptions->setTidy( true );
-
-                               if ( !$this->mNewRev->isCurrent() ) {
-                                       $parserOptions->setEditSection( false );
-                               }
-
-                               $parserOutput = $wikiPage->getParserOutput( $parserOptions, $this->mNewid );
+                               $parserOutput = $this->getParserOutput( $wikiPage, $this->mNewRev );
 
                                # WikiPage::getParserOutput() should not return false, but just in case
                                if( $parserOutput ) {
@@ -549,6 +541,19 @@ class DifferenceEngine extends ContextSource {
                wfProfileOut( __METHOD__ );
        }
 
+       protected function getParserOutput( WikiPage $page, Revision $rev ) {
+               $parserOptions = ParserOptions::newFromContext( $this->getContext() );
+               $parserOptions->enableLimitReport();
+               $parserOptions->setTidy( true );
+
+               if ( !$rev->isCurrent() || !$rev->getTitle()->quickUserCan( "edit" ) ) {
+                       $parserOptions->setEditSection( false );
+               }
+
+               $parserOutput = $page->getParserOutput( $parserOptions, $rev->getId() );
+               return $parserOutput;
+       }
+
        /**
         * Get the diff text, send it to the OutputPage object
         * Returns false if the diff could not be generated, otherwise returns true