r91496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91495‎ | r91496 | r91497 >
Date:21:32, 5 July 2011
Author:aaron
Status:deferred (Comments)
Tags:
Comment:
DumpHTML fixes:
* Made SkinOffline use getTitle() instead of non-existing mTitle
* Made getArticleHTML() use RequestContext (follow-up r85250)
Modified paths:
  • /trunk/extensions/DumpHTML/SkinOffline.php (modified) (history)
  • /trunk/extensions/DumpHTML/dumpHTML.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/DumpHTML/dumpHTML.inc
@@ -786,37 +786,36 @@
787787 /** Reads the content of a title object, executes the skin and captures the result */
788788 function getArticleHTML( $title ) {
789789 global $wgOut, $wgTitle, $wgUser;
790 -
791 - $linkCache =& LinkCache::singleton();
792 - $linkCache->clear();
793 - $wgTitle = $title;
794 - if ( is_null( $wgTitle ) ) {
 790+ if ( is_null( $title ) ) {
795791 return false;
796792 }
 793+ $linkCache =& LinkCache::singleton();
 794+ $linkCache->clear();
797795
 796+ $context = new RequestContext();
 797+ $context->setTitle( $title );
 798+ $context->setUser( $wgUser );
 799+
 800+ $wgTitle = $title; // b/c
 801+ $wgOut = new OutputPage( $context );
 802+ $wgOut->parserOptions( new ParserOptions() ); // anon
 803+
 804+ $context->setOutput( $wgOut );
 805+
798806 $ns = $wgTitle->getNamespace();
799807 if ( $ns == NS_SPECIAL ) {
800 - $wgOut = new OutputPage;
801 - $wgOut->parserOptions( new ParserOptions );
802 - $wgOut->setTitle( $title );
803 - SpecialPage::executePath( $wgTitle, RequestContext::getMain() );
 808+ SpecialPage::executePath( $wgTitle, $context );
804809 } else {
805 - $article = MediaWiki::articleFromTitle( $wgTitle, RequestContext::getMain() );
 810+ $article = MediaWiki::articleFromTitle( $wgTitle, $context );
806811 $rt = $article->followRedirect();
807812 if ( is_object( $rt ) ) {
808813 return $this->getRedirect( $rt );
809814 } else {
810 - $wgOut = new OutputPage;
811 - $wgOut->parserOptions( new ParserOptions );
812 - $wgOut->setTitle( $title );
813 -
814815 $article->view();
815816 }
816817 }
817818
818 -
819 - $sk = $wgUser->getSkin();
820 - $sk->setTitle( $title );
 819+ $sk = $context->getSkin();
821820 ob_start();
822821 $sk->outputPage( $wgOut );
823822 $text = ob_get_contents();
Index: trunk/extensions/DumpHTML/SkinOffline.php
@@ -48,15 +48,15 @@
4949 $content_actions = array();
5050 $nskey = $this->getNameSpaceKey();
5151 $content_actions[$nskey] = $this->tabAction(
52 - $this->mTitle->getSubjectPage(),
 52+ $this->getTitle()->getSubjectPage(),
5353 $nskey,
54 - !$this->mTitle->isTalkPage() );
 54+ !$this->getTitle()->isTalkPage() );
5555
56 - if( $this->mTitle->canTalk() ) {
 56+ if( $this->getTitle()->canTalk() ) {
5757 $content_actions['talk'] = $this->tabAction(
58 - $this->mTitle->getTalkPage(),
 58+ $this->getTitle()->getTalkPage(),
5959 'talk',
60 - $this->mTitle->isTalkPage(),
 60+ $this->getTitle()->isTalkPage(),
6161 '',
6262 true);
6363 }
@@ -64,7 +64,7 @@
6565 if ( isset( $wgHTMLDump ) ) {
6666 $content_actions['current'] = array(
6767 'text' => wfMsg( 'currentrev' ),
68 - 'href' => str_replace( '$1', wfUrlencode( $this->mTitle->getPrefixedDBkey() ),
 68+ 'href' => str_replace( '$1', wfUrlencode( $this->getTitle()->getPrefixedDBkey() ),
6969 $wgHTMLDump->oldArticlePath ),
7070 'class' => false
7171 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r91529Follow-up r91496: just use $context->getOutput() instead of OutputPage constr...aaron06:32, 6 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85250Continue with r85240; Move getSkin from User to RequestContext, do it without...dantman12:46, 3 April 2011

Comments

#Comment by Dantman (talk | contribs)   02:57, 6 July 2011

Wrong way to handle OutputPage.

That should be:

$context = new RequestContext();
$context->setTitle( $title );
$context->setUser( $wgUser );

$wgTitle = $title; // b/c
$wgOut = $context->getOutput();
$wgOut->parserOptions( new ParserOptions() ); // anon

ie: Don't create your own OutputPage and set it, the RequestContext does it on it's own. Just fetch the one inside the context then use and alter it.

Status & tagging log