Follow-up r85302: update OutputPage constructors in core.
authorHappy-melon <happy-melon@users.mediawiki.org>
Tue, 5 Apr 2011 00:06:47 +0000 (00:06 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Tue, 5 Apr 2011 00:06:47 +0000 (00:06 +0000)
includes/OutputPage.php
includes/api/ApiParse.php
maintenance/rebuildFileCache.php
tests/parser/parserTest.inc
tests/phpunit/includes/parser/NewParserTest.php

index e135e07..821051e 100644 (file)
@@ -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__ );
                }
index 5faf8f5..8b9d272 100644 (file)
@@ -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 ) );
                        }
                }
 
index 841bbcd..01b7b1f 100644 (file)
@@ -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
index 09d7db9..02767b3 100644 (file)
@@ -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;
 
index b37f8c3..a52ab1e 100644 (file)
@@ -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;