r108520 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108519‎ | r108520 | r108521 >
Date:17:06, 10 January 2012
Author:ialex
Status:ok
Tags:
Comment:
* Set global variables from the newly created context, instead of the opposite, as we do in special page inclusion.
* Use local variables where possible instead of global ones
Modified paths:
  • /trunk/extensions/DumpHTML/dumpHTML.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/DumpHTML/dumpHTML.inc
@@ -781,27 +781,30 @@
782782
783783 /** Reads the content of a title object, executes the skin and captures the result */
784784 function getArticleHTML( $title ) {
785 - global $wgOut, $wgTitle, $wgUser;
 785+ global $wgOut, $wgTitle, $wgUser, $wgRequest;
 786+
786787 if ( is_null( $title ) ) {
787788 return false;
788789 }
 790+
789791 LinkCache::singleton()->clear();
790792
791793 $context = new RequestContext();
792794 $context->setRequest( new DumpFauxRequest( $title->getLocalUrl(),
793 - array( 'title' => $title->getPrefixedDbKey() ) ) );
 795+ array( 'title' => $title->getPrefixedDbKey() ) ) );
794796 $context->setTitle( $title );
795 - $context->setUser( $wgUser );
796797
797 - $wgTitle = $title; // b/c
798 - $wgOut = $context->getOutput(); // b/c
799 - $wgOut->parserOptions( new ParserOptions() ); // anon
 798+ // b/c
 799+ $wgTitle = $title;
 800+ $wgOut = $context->getOutput();
 801+ $wgUser = $context->getUser();
 802+ $wgRequest = $context->getRequest();
800803
801 - $ns = $wgTitle->getNamespace();
 804+ $ns = $title->getNamespace();
802805 if ( $ns == NS_SPECIAL ) {
803 - SpecialPage::executePath( $wgTitle, $context );
 806+ SpecialPage::executePath( $title, $context );
804807 } else {
805 - $article = Article::newFromTitle( $wgTitle, $context );
 808+ $article = Article::newFromTitle( $title, $context );
806809 $rt = $article->followRedirect();
807810 if ( is_object( $rt ) ) {
808811 return $this->getRedirect( $rt );
@@ -810,9 +813,8 @@
811814 }
812815 }
813816
814 - $sk = $context->getSkin();
815817 ob_start();
816 - $sk->outputPage( $wgOut );
 818+ $context->getSkin()->outputPage( $context->getOutput() );
817819 $text = ob_get_contents();
818820 ob_end_clean();
819821

Status & tagging log