Merge "Fixing creation of DifferenceEninge" into Wikidata
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 28 Aug 2012 11:44:44 +0000 (11:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 Aug 2012 11:44:44 +0000 (11:44 +0000)
1  2 
includes/Article.php

diff --combined includes/Article.php
@@@ -391,7 -391,7 +391,7 @@@ class Article extends Page 
                $content = $this->fetchContentObject();
  
                $this->mContent = ContentHandler::getContentText( $content ); #@todo: get rid of mContent everywhere!
 -              wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) ); #BC cruft, deprecated!
 +              ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
  
                wfProfileOut( __METHOD__ );
  
                                                wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
                                                $this->showCssOrJsPage();
                                                $outputDone = true;
 -                                      } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
 +                                      } elseif( !wfRunHooks( 'ArticleContentViewCustom',
 +                                                                                      array( $this->fetchContentObject(), $this->getTitle(),
 +                                                                                                      $outputPage ) ) ) {
 +
                                                # Allow extensions do their own custom view for certain pages
                                                $outputDone = true;
 -                                      } elseif( Hooks::isRegistered( 'ArticleViewCustom' ) && !wfRunHooks( 'ArticleViewCustom', array( $this->fetchContent(), $this->getTitle(), $outputPage ) ) ) { #FIXME: fetchContent() is deprecated!
 +                                      } elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
 +                                                                                                                              array( $this->fetchContentObject(), $this->getTitle(),
 +                                                                                                                                              $outputPage ) ) ) {
 +
                                                # Allow extensions do their own custom view for certain pages
                                                $outputDone = true;
                                        } else {
                                                        # Viewing a redirect page (e.g. with parameter redirect=no)
                                                        $outputPage->addHTML( $this->viewRedirect( $rt ) );
                                                        # Parse just to get categories, displaytitle, etc.
 -                                                      $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions, false );
 +                                                      $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid,
 +                                                                                                                                                              $parserOptions, false );
                                                        $outputPage->addParserOutputNoText( $this->mParserOutput );
                                                        $outputDone = true;
                                                }
        /**
         * Show a diff page according to current request variables. For use within
         * Article::view() only, other callers should use the DifferenceEngine class.
+        *
+        * @todo: make protected
         */
        public function showDiffPage() {
                $request = $this->getContext()->getRequest();
                $unhide = $request->getInt( 'unhide' ) == 1;
                $oldid = $this->getOldID();
  
-               $contentHandler = ContentHandler::getForTitle( $this->getTitle() );
+               $rev = $this->getRevisionFetched();
+               if ( !$rev ) {
+                       $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' )->text() );
+                       $this->getContext()->getOutput()->addWikiMsg( 'difference-missing-revision', $oldid, 1 );
+                       return;
+               }
+               $contentHandler = $rev->getContentHandler();
                $de = $contentHandler->createDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
  
                // DifferenceEngine directly fetched the revision:
                }
  
                // Give hooks a chance to customise the output
 -              if ( !Hooks::isRegistered('ShowRawCssJs') || wfRunHooks( 'ShowRawCssJs', array( $this->fetchContent(), $this->getTitle(), $wgOut ) ) ) { #FIXME: fetchContent() is deprecated
 +              if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->fetchContentObject(), $this->getTitle(), $wgOut ) ) ) {
                        $po = $this->mContentObject->getParserOutput( $this->getTitle() );
                        $wgOut->addHTML( $po->getText() );
                }
         * @return ParserOutput or false if the given revsion ID is not found
         */
        public function getParserOutput( $oldid = null, User $user = null ) {
 +              //XXX: bypasses mParserOptions and thus setParserOptions()
 +
                $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
 -              $parserOptions = $this->mPage->makeParserOptions( $user ); //XXX: bypasses mParserOptions and thus setParserOptions()
 +              $parserOptions = $this->mPage->makeParserOptions( $user );
  
                return $this->mPage->getParserOutput( $parserOptions, $oldid );
        }