Instead of creating an OutputPage and then setting a context start initializing Outpu...
authorDaniel Friesen <dantman@users.mediawiki.org>
Mon, 4 Apr 2011 00:37:42 +0000 (00:37 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Mon, 4 Apr 2011 00:37:42 +0000 (00:37 +0000)
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.

includes/OutputPage.php
includes/RequestContext.php
includes/SpecialPage.php

index 4c7b2e9..03fc907 100644 (file)
@@ -190,11 +190,7 @@ class OutputPage {
        /// should be private. To include the variable {{REVISIONID}}
        var $mRevisionId = null;
 
-       /// Stores a Title object (of the current page).
-       protected $mTitle = null;
-
-       /// Stores a User object (the one the page is being rendered for)
-       protected $mUser = null;
+       private $mContext;
 
        /**
         * An array of stylesheet filenames (relative from skins path), with options
@@ -218,6 +214,19 @@ class OutputPage {
                'Cookie' => null
        );
 
+       /**
+        * Constructor for OutputPage. This should not be called directly.
+        * Instead a new RequestContext should be created and it will implicitly create
+        * a OutputPage tied to that context.
+        */
+       function __construct( RequestContext $context=null ) {
+               if ( !isset($context) ) {
+                       # Extensions should use `new RequestContext` instead of `new OutputPage` now.
+                       wfDeprecated( __METHOD__ );
+               }
+               $this->mContext = $context;
+       }
+
        /**
         * Redirect to $url rather than displaying the normal page
         *
@@ -751,15 +760,6 @@ class OutputPage {
                return $this->mPagetitle;
        }
 
-       /**
-        * Set the RequestContext used in this instance
-        *
-        * @param RequestContext $context
-        */
-       public function setContext( RequestContext $context ) {
-               $this->mContext = $context;
-       }
-
        /**
         * Get the RequestContext used in this instance
         *
index 4fd7222..d90ddd0 100644 (file)
@@ -66,8 +66,7 @@ class RequestContext {
         */
        public function getOutput() {
                if ( !isset( $this->mOutput ) ) {
-                       $this->mOutput = new OutputPage;
-                       $this->mOutput->setContext( $this );
+                       $this->mOutput = new OutputPage( $this );
                }
                return $this->mOutput;
        }
index 779edca..44aaf56 100644 (file)
@@ -609,14 +609,6 @@ class SpecialPage {
        static function capturePath( &$title ) {
                global $wgOut, $wgTitle;
 
-               // preload the skin - Sometimes the SpecialPage loads it at a bad point in time making a includable special page override the skin title
-               // This hack is ok for now. The plan is for
-               // - Skin to stop storing it's own title
-               // - includable special pages to stop using $wgTitle and $wgOut
-               // - and OutputPage to store it's own skin object instead of askin $wgUser
-               // Once just about any of those are implemented preloading will not be necessarily
-               $wgOut->getSkin();
-
                $oldTitle = $wgTitle;
                $oldOut = $wgOut;