From 625695317ea89a66820c7ddded3e1a9aa7367acc Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Tue, 5 Apr 2011 00:06:47 +0000 Subject: [PATCH] Follow-up r85302: update OutputPage constructors in core. --- includes/OutputPage.php | 1 + includes/api/ApiParse.php | 14 ++++++-------- maintenance/rebuildFileCache.php | 5 +++-- tests/parser/parserTest.inc | 8 ++++---- tests/phpunit/includes/parser/NewParserTest.php | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index e135e072a6..821051e0d7 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -221,6 +221,7 @@ class OutputPage { */ function __construct( RequestContext $context = null ) { if ( !isset($context) ) { +var_dump('foo'); # Extensions should use `new RequestContext` instead of `new OutputPage` now. wfDeprecated( __METHOD__ ); } diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 5faf8f5ede..8b9d272eb2 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -251,25 +251,23 @@ class ApiParse extends ApiBase { } if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) { - $out = new OutputPage; - $out->setUser( $wgUser ); - $out->addParserOutputNoText( $p_result ); - $userSkin = $wgUser->getSkin(); + $context = new RequestContext; + $context->output->addParserOutputNoText( $p_result ); if ( isset( $prop['headitems'] ) ) { $headItems = $this->formatHeadItems( $p_result->getHeadItems() ); - $userSkin->setupUserCss( $out ); - $css = $this->formatCss( $out->buildCssLinksArray() ); + $context->skin->setupUserCss( $context->output ); + $css = $this->formatCss( $context->output->buildCssLinksArray() ); - $scripts = array( $out->getHeadScripts( $userSkin ) ); + $scripts = array( $context->output->getHeadScripts( $context->skin ) ); $result_array['headitems'] = array_merge( $headItems, $css, $scripts ); } if ( isset( $prop['headhtml'] ) ) { $result_array['headhtml'] = array(); - $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) ); + $result->setContent( $result_array['headhtml'], $context->output->headElement( $context->skin ) ); } } diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 841bbcda90..01b7b1f52c 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -72,12 +72,14 @@ class RebuildFileCache extends Maintenance { foreach ( $res as $row ) { $rebuilt = false; $wgRequestTime = wfTime(); # bug 22852 + $context = new RequestContext; $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); + $context->setTitle( $wgTitle ); if ( null == $wgTitle ) { $this->output( "Page {$row->page_id} has bad title\n" ); continue; // broken title? } - $wgOut->setTitle( $wgTitle ); // set display title + $wgOut = $context->output; // set display title $wgUser->getSkin( $wgTitle ); // set skin title $wgArticle = new Article( $wgTitle ); // If the article is cacheable, then load it @@ -97,7 +99,6 @@ class RebuildFileCache extends Maintenance { @$wgOut->output(); // header notices $wgUseFileCache = true; ob_end_clean(); // clear buffer - $wgOut = new OutputPage(); // empty out any output page garbage if ( $rebuilt ) $this->output( "Re-cached page {$row->page_id}\n" ); else diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 09d7db924e..02767b3020 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -680,11 +680,11 @@ class ParserTest { $GLOBALS[$var] = $val; } - $langObj = Language::factory( $lang ); - $GLOBALS['wgLang'] = $langObj; - $GLOBALS['wgContLang'] = $langObj; + $context = new RequestContext(); + $GLOBALS['wgLang'] = $context->lang; + $GLOBALS['wgContLang'] = $context->lang; $GLOBALS['wgMemc'] = new EmptyBagOStuff; - $GLOBALS['wgOut'] = new OutputPage; + $GLOBALS['wgOut'] = new $context->output; global $wgHooks; diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index b37f8c3ba3..a52ab1e276 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -295,11 +295,11 @@ class NewParserTest extends MediaWikiTestCase { $GLOBALS[$var] = $val; } - $langObj = Language::factory( $lang ); - $GLOBALS['wgLang'] = $langObj; - $GLOBALS['wgContLang'] = $langObj; + $context = new RequestContext(); + $GLOBALS['wgLang'] = $context->lang; + $GLOBALS['wgContLang'] = $context->lang; $GLOBALS['wgMemc'] = new EmptyBagOStuff; - $GLOBALS['wgOut'] = new OutputPage; + $GLOBALS['wgOut'] = new $context->output; global $wgHooks; -- 2.20.1