r85302 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85301‎ | r85302 | r85303 >
Date:00:37, 4 April 2011
Author:dantman
Status:resolved (Comments)
Tags:
Comment:
Instead of creating an OutputPage and then setting a context start initializing OutputPages 'with' a context and send depreciated calls to extensions directly creating OutputPage instances.
Now that we've taken care of the mess of mTitle inside OutputPage and Skin and made RequestContext track Skin instead of $wgUser we don't need the hack in SpecialPage anymore.
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/RequestContext.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -609,14 +609,6 @@
610610 static function capturePath( &$title ) {
611611 global $wgOut, $wgTitle;
612612
613 - // preload the skin - Sometimes the SpecialPage loads it at a bad point in time making a includable special page override the skin title
614 - // This hack is ok for now. The plan is for
615 - // - Skin to stop storing it's own title
616 - // - includable special pages to stop using $wgTitle and $wgOut
617 - // - and OutputPage to store it's own skin object instead of askin $wgUser
618 - // Once just about any of those are implemented preloading will not be necessarily
619 - $wgOut->getSkin();
620 -
621613 $oldTitle = $wgTitle;
622614 $oldOut = $wgOut;
623615
Index: trunk/phase3/includes/RequestContext.php
@@ -66,8 +66,7 @@
6767 */
6868 public function getOutput() {
6969 if ( !isset( $this->mOutput ) ) {
70 - $this->mOutput = new OutputPage;
71 - $this->mOutput->setContext( $this );
 70+ $this->mOutput = new OutputPage( $this );
7271 }
7372 return $this->mOutput;
7473 }
Index: trunk/phase3/includes/OutputPage.php
@@ -190,12 +190,8 @@
191191 /// should be private. To include the variable {{REVISIONID}}
192192 var $mRevisionId = null;
193193
194 - /// Stores a Title object (of the current page).
195 - protected $mTitle = null;
 194+ private $mContext;
196195
197 - /// Stores a User object (the one the page is being rendered for)
198 - protected $mUser = null;
199 -
200196 /**
201197 * An array of stylesheet filenames (relative from skins path), with options
202198 * for CSS media, IE conditions, and RTL/LTR direction.
@@ -219,6 +215,19 @@
220216 );
221217
222218 /**
 219+ * Constructor for OutputPage. This should not be called directly.
 220+ * Instead a new RequestContext should be created and it will implicitly create
 221+ * a OutputPage tied to that context.
 222+ */
 223+ function __construct( RequestContext $context=null ) {
 224+ if ( !isset($context) ) {
 225+ # Extensions should use `new RequestContext` instead of `new OutputPage` now.
 226+ wfDeprecated( __METHOD__ );
 227+ }
 228+ $this->mContext = $context;
 229+ }
 230+
 231+ /**
223232 * Redirect to $url rather than displaying the normal page
224233 *
225234 * @param $url String: URL
@@ -752,15 +761,6 @@
753762 }
754763
755764 /**
756 - * Set the RequestContext used in this instance
757 - *
758 - * @param RequestContext $context
759 - */
760 - public function setContext( RequestContext $context ) {
761 - $this->mContext = $context;
762 - }
763 -
764 - /**
765765 * Get the RequestContext used in this instance
766766 *
767767 * @return RequestContext

Follow-up revisions

RevisionCommit summaryAuthorDate
r85317Follow-up r85302: whitespace fixnikerabbit07:24, 4 April 2011
r85332Fix fatal in SpecialCite introduced in the Context rewrite. Reported on r853...happy-melon15:26, 4 April 2011
r85403Follow-up r85302: update OutputPage constructors in core.happy-melon00:06, 5 April 2011
r85584Follow-up r85302: new MediaWiki() constructor format in phpunit test declarat...happy-melon21:59, 6 April 2011
r94763Followup fixme for r85302; Removing the wfDeprecated call from new OutputPage...dantman14:19, 17 August 2011

Comments

#Comment by Raymond (talk | contribs)   14:59, 4 April 2011

I am unsure if this revision is the right culprit for this fatal:

Notice: Undefined property: SkinVector::$mTitle in D:\F_Programmierung\xampp\htdocs\wiki2\extensions\Cite\SpecialCite.php on line 39
Fatal error: Call to a member function isContentPage() on a non-object in D:\F_Programmierung\xampp\htdocs\wiki2\extensions\Cite\SpecialCite.php on line 39
#Comment by Happy-melon (talk | contribs)   15:27, 4 April 2011

Heaven knows :D Should be fixed in r85332 though.

#Comment by Platonides (talk | contribs)   20:05, 4 April 2011

parserTests.php creates a new OutputPage.

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

Fixed in r85403

#Comment by Platonides (talk | contribs)   21:53, 6 April 2011

Argument 1 passed to MediaWiki::__construct() must be an instance of RequestContext, none given, called in phase3/tests/phpunit/includes/MediaWikiTest.php on line 13

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

I am rapidly losing faith in my IDE's search function... :S. Fixed in r85584.

#Comment by Nikerabbit (talk | contribs)   12:39, 17 June 2011

PHP Notice: Use of OutputPage::__construct is deprecated. [Called from LqtView::getInlineEditForm in /www/w/extensions/LiquidThreads/classes/View.php at line 362] in /www/w/includes/GlobalFunctions.php on line 3342

#Comment by Werdna (talk | contribs)   13:16, 17 June 2011

Please update (or at least email) callers before you do stuff like this. It's very frustrating for you to expect extension authors to notice that their sites are suddenly throwing endless PHP notices and to change their calling conventions. In general you should support old calling conventions as much as possible.

#Comment by Nikerabbit (talk | contribs)   13:43, 17 June 2011

Normal sites don't have $wgDevelopmentWarnings enabled, or at least shouldn't.

#Comment by 😂 (talk | contribs)   18:33, 28 June 2011

Even more reason to not deprecate things so quickly...most people don't have that enabled.

#Comment by Dantman (talk | contribs)   14:21, 17 August 2011

Removed the deprecation notice for 1.18 in r94763.

Status & tagging log