r85403 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85402‎ | r85403 | r85404 >
Date:00:06, 5 April 2011
Author:happy-melon
Status:resolved (Comments)
Tags:
Comment:
Follow-up r85302: update OutputPage constructors in core.
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildFileCache.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildFileCache.php
@@ -72,12 +72,14 @@
7373 foreach ( $res as $row ) {
7474 $rebuilt = false;
7575 $wgRequestTime = wfTime(); # bug 22852
 76+ $context = new RequestContext;
7677 $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
 78+ $context->setTitle( $wgTitle );
7779 if ( null == $wgTitle ) {
7880 $this->output( "Page {$row->page_id} has bad title\n" );
7981 continue; // broken title?
8082 }
81 - $wgOut->setTitle( $wgTitle ); // set display title
 83+ $wgOut = $context->output; // set display title
8284 $wgUser->getSkin( $wgTitle ); // set skin title
8385 $wgArticle = new Article( $wgTitle );
8486 // If the article is cacheable, then load it
@@ -97,7 +99,6 @@
98100 @$wgOut->output(); // header notices
99101 $wgUseFileCache = true;
100102 ob_end_clean(); // clear buffer
101 - $wgOut = new OutputPage(); // empty out any output page garbage
102103 if ( $rebuilt )
103104 $this->output( "Re-cached page {$row->page_id}\n" );
104105 else
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -295,11 +295,11 @@
296296 $GLOBALS[$var] = $val;
297297 }
298298
299 - $langObj = Language::factory( $lang );
300 - $GLOBALS['wgLang'] = $langObj;
301 - $GLOBALS['wgContLang'] = $langObj;
 299+ $context = new RequestContext();
 300+ $GLOBALS['wgLang'] = $context->lang;
 301+ $GLOBALS['wgContLang'] = $context->lang;
302302 $GLOBALS['wgMemc'] = new EmptyBagOStuff;
303 - $GLOBALS['wgOut'] = new OutputPage;
 303+ $GLOBALS['wgOut'] = new $context->output;
304304
305305 global $wgHooks;
306306
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -680,11 +680,11 @@
681681 $GLOBALS[$var] = $val;
682682 }
683683
684 - $langObj = Language::factory( $lang );
685 - $GLOBALS['wgLang'] = $langObj;
686 - $GLOBALS['wgContLang'] = $langObj;
 684+ $context = new RequestContext();
 685+ $GLOBALS['wgLang'] = $context->lang;
 686+ $GLOBALS['wgContLang'] = $context->lang;
687687 $GLOBALS['wgMemc'] = new EmptyBagOStuff;
688 - $GLOBALS['wgOut'] = new OutputPage;
 688+ $GLOBALS['wgOut'] = new $context->output;
689689
690690 global $wgHooks;
691691
Index: trunk/phase3/includes/OutputPage.php
@@ -221,6 +221,7 @@
222222 */
223223 function __construct( RequestContext $context = null ) {
224224 if ( !isset($context) ) {
 225+var_dump('foo');
225226 # Extensions should use `new RequestContext` instead of `new OutputPage` now.
226227 wfDeprecated( __METHOD__ );
227228 }
Index: trunk/phase3/includes/api/ApiParse.php
@@ -251,25 +251,23 @@
252252 }
253253
254254 if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
255 - $out = new OutputPage;
256 - $out->setUser( $wgUser );
257 - $out->addParserOutputNoText( $p_result );
258 - $userSkin = $wgUser->getSkin();
 255+ $context = new RequestContext;
 256+ $context->output->addParserOutputNoText( $p_result );
259257
260258 if ( isset( $prop['headitems'] ) ) {
261259 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
262260
263 - $userSkin->setupUserCss( $out );
264 - $css = $this->formatCss( $out->buildCssLinksArray() );
 261+ $context->skin->setupUserCss( $context->output );
 262+ $css = $this->formatCss( $context->output->buildCssLinksArray() );
265263
266 - $scripts = array( $out->getHeadScripts( $userSkin ) );
 264+ $scripts = array( $context->output->getHeadScripts( $context->skin ) );
267265
268266 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
269267 }
270268
271269 if ( isset( $prop['headhtml'] ) ) {
272270 $result_array['headhtml'] = array();
273 - $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) );
 271+ $result->setContent( $result_array['headhtml'], $context->output->headElement( $context->skin ) );
274272 }
275273 }
276274

Follow-up revisions

RevisionCommit summaryAuthorDate
r85430Follow-up r85403: rm debugging code and a defunct method call.happy-melon10:44, 5 April 2011
r85553Follow-up r85403: fix fatal in parser tests.happy-melon17:39, 6 April 2011
r88665Follow-up r85403: rm unwanted "new" declaration.happy-melon18:57, 23 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85302Instead of creating an OutputPage and then setting a context start initializi...dantman00:37, 4 April 2011

Comments

#Comment by Dantman (talk | contribs)   00:25, 5 April 2011

You can also drop $wgUser->getSkin( $wgTitle ); // set skin title it's not needed.

#Comment by Siebrand (talk | contribs)   06:03, 5 April 2011

FIXME:

+var_dump('foo');

#Comment by Happy-melon (talk | contribs)   10:44, 5 April 2011

Lol.

#Comment by Platonides (talk | contribs)   23:22, 5 April 2011

$ php tests/parserTests.php

PHP Fatal error: Call to a member function getDefaultUserOptionOverrides() on a non-object in User.php:1071 User.php:1963 RequestContext.php:108 RequestContext.php:194 parserTest.inc:684 parserTest.inc:427 parserTest.inc:374 parserTest.inc:356 parserTests.php:90 includes/User.php on line 1071

Reason: You are removing the Language::factory( $lang );

#Comment by Happy-melon (talk | contribs)   17:40, 6 April 2011

Fixed in r85553.

#Comment by Bawolff (talk | contribs)   17:20, 23 May 2011

In ParserTests.inc/NewParserTests.inc - shouldn't that be $GLOBALS['wgOut'] = $context->output; not $GLOBALS['wgOut'] = new' $context->output;? I think this causes:

Notice: Use of OutputPage::__construct is deprecated. [Called from ParserTest::setupGlobals in /var/www/w/phase3/tests/parser/parserTest.inc at line 687] in /var/www/w/phase3/includes/GlobalFunctions.php on line 3243

#Comment by Happy-melon (talk | contribs)   18:27, 23 May 2011

I think the intended semantic was (new RequestContext)->output, if that even parses, although it looks like I switched halfway to a temporary variable and didn't finish the job...

#Comment by Happy-melon (talk | contribs)   18:57, 23 May 2011

Fixed in r88665.

Status & tagging log