Use IContextSource instead of RequestContext inside type hints and instanceof checks...
authorDaniel Friesen <dantman@users.mediawiki.org>
Thu, 15 Sep 2011 15:19:49 +0000 (15:19 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Thu, 15 Sep 2011 15:19:49 +0000 (15:19 +0000)
14 files changed:
includes/Action.php
includes/Article.php
includes/ChangesList.php
includes/HTMLForm.php
includes/OutputPage.php
includes/Preferences.php
includes/RequestContext.php
includes/RevisionList.php
includes/SpecialPage.php
includes/SpecialPageFactory.php
includes/Wiki.php
includes/logging/LogFormatter.php
includes/revisiondelete/RevisionDeleteAbstracts.php
includes/specials/SpecialUpload.php

index e836098..b165721 100644 (file)
@@ -32,8 +32,8 @@ abstract class Action {
        protected $page;
 
        /**
-        * RequestContext if specified; otherwise we'll use the Context from the Page
-        * @var RequestContext
+        * IContextSource if specified; otherwise we'll use the Context from the Page
+        * @var IContextSource
         */
        protected $context;
 
@@ -96,11 +96,11 @@ abstract class Action {
        }
 
        /**
-        * Get the RequestContext in use here
-        * @return RequestContext
+        * Get the IContextSource in use here
+        * @return IContextSource
         */
        protected final function getContext() {
-               if ( $this->context instanceof RequestContext ) {
+               if ( $this->context instanceof IContextSource ) {
                        return $this->context;
                }
                return $this->page->getContext();
index e453b37..3dcef85 100644 (file)
@@ -23,7 +23,7 @@ class Article extends Page {
         */
 
        /**
-        * @var RequestContext
+        * @var IContextSource
         */
        protected $mContext;
 
@@ -88,10 +88,10 @@ class Article extends Page {
         * Create an Article object of the appropriate class for the given page.
         *
         * @param $title Title
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @return Article object
         */
-       public static function newFromTitle( $title, RequestContext $context ) {
+       public static function newFromTitle( $title, IContextSource $context ) {
                if ( NS_MEDIA == $title->getNamespace() ) {
                        // FIXME: where should this go?
                        $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
@@ -1856,7 +1856,7 @@ class Article extends Page {
        /**
         * Sets the context this Article is executed in
         *
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @since 1.18
         */
        public function setContext( $context ) {
@@ -1866,11 +1866,11 @@ class Article extends Page {
        /**
         * Gets the context this Article is executed in
         *
-        * @return RequestContext
+        * @return IContextSource
         * @since 1.18
         */
        public function getContext() {
-               if ( $this->mContext instanceof RequestContext ) {
+               if ( $this->mContext instanceof IContextSource ) {
                        return $this->mContext;
                } else {
                        wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
index bb36ce9..fe40cd4 100644 (file)
@@ -45,10 +45,10 @@ class ChangesList extends ContextSource {
        /**
         * Changeslist contructor
         *
-        * @param $obj Skin or RequestContext
+        * @param $obj Skin or IContextSource
         */
        public function __construct( $obj ) {
-               if ( $obj instanceof RequestContext ) {
+               if ( $obj instanceof IContextSource ) {
                        $this->setContext( $obj );
                        $this->skin = $obj->getSkin();
                } else {
@@ -74,10 +74,10 @@ class ChangesList extends ContextSource {
         * Fetch an appropriate changes list class for the specified context
         * Some users might want to use an enhanced list format, for instance
         *
-        * @param $context RequestContext to use
+        * @param $context IContextSource to use
         * @return ChangesList|EnhancedChangesList|OldChangesList derivative
         */
-       public static function newFromContext( RequestContext $context ) {
+       public static function newFromContext( IContextSource $context ) {
                $user = $context->getUser();
                $sk = $context->getSkin();
                $list = null;
index da84fc3..c8279bc 100644 (file)
@@ -102,7 +102,7 @@ class HTMLForm {
        protected $mSubmitText;
        protected $mSubmitTooltip;
 
-       protected $mContext; // <! RequestContext
+       protected $mContext; // <! IContextSource
        protected $mTitle;
        protected $mMethod = 'post';
 
@@ -115,12 +115,12 @@ class HTMLForm {
        /**
         * Build a new HTMLForm from an array of field attributes
         * @param $descriptor Array of Field constructs, as described above
-        * @param $context RequestContext available since 1.18, will become compulsory in 1.18.
+        * @param $context IContextSource available since 1.18, will become compulsory in 1.18.
         *     Obviates the need to call $form->setTitle()
         * @param $messagePrefix String a prefix to go in front of default messages
         */
-       public function __construct( $descriptor, /*RequestContext*/ $context = null, $messagePrefix = '' ) {
-               if( $context instanceof RequestContext ){
+       public function __construct( $descriptor, /*IContextSource*/ $context = null, $messagePrefix = '' ) {
+               if( $context instanceof IContextSource ){
                        $this->mContext = $context;
                        $this->mTitle = false; // We don't need them to set a title
                        $this->mMessagePrefix = $messagePrefix;
@@ -638,10 +638,10 @@ class HTMLForm {
        }
 
        /**
-        * @return RequestContext
+        * @return IContextSource
         */
        public function getContext(){
-               return $this->mContext instanceof RequestContext
+               return $this->mContext instanceof IContextSource
                        ? $this->mContext
                        : RequestContext::getMain();
        }
index 7760d15..8a97061 100644 (file)
@@ -223,7 +223,7 @@ class OutputPage extends ContextSource {
         * Instead a new RequestContext should be created and it will implicitly create
         * a OutputPage tied to that context.
         */
-       function __construct( RequestContext $context = null ) {
+       function __construct( IContextSource $context = null ) {
                if ( $context === null ) {
                        # Extensions should use `new RequestContext` instead of `new OutputPage` now.
                        wfDeprecated( __METHOD__ );
index 9f4e5b2..a955b6f 100644 (file)
@@ -1212,11 +1212,11 @@ class Preferences {
 
        /**
         * @param $user User
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @param $formClass string
         * @return HtmlForm
         */
-       static function getFormObject( $user, RequestContext $context, $formClass = 'PreferencesForm' ) {
+       static function getFormObject( $user, IContextSource $context, $formClass = 'PreferencesForm' ) {
                $formDescriptor = Preferences::getPreferences( $user );
                $htmlForm = new $formClass( $formDescriptor, $context, 'prefs' );
 
index e3a19a3..298ab27 100644 (file)
@@ -353,14 +353,14 @@ class RequestContext implements IContextSource {
 abstract class ContextSource implements IContextSource {
 
        /**
-        * @var RequestContext
+        * @var IContextSource
         */
        private $context;
 
        /**
-        * Get the RequestContext object
+        * Get the IContextSource object
         *
-        * @return RequestContext
+        * @return IContextSource
         */
        public function getContext() {
                if ( $this->context === null ) {
@@ -372,11 +372,11 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Set the RequestContext object
+        * Set the IContextSource object
         *
-        * @param $context RequestContext
+        * @param $context IContextSource
         */
-       public function setContext( RequestContext $context ) {
+       public function setContext( IContextSource $context ) {
                $this->context = $context;
        }
 
index dfb85ee..215b663 100644 (file)
@@ -8,7 +8,7 @@ abstract class RevisionListBase {
         */
        var $title;
        /**
-        * @var RequestContext
+        * @var IContextSource
         */
        var $context;
 
@@ -16,10 +16,10 @@ abstract class RevisionListBase {
 
        /**
         * Construct a revision list for a given title
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @param $title Title
         */
-       function __construct( RequestContext $context, Title $title ) {
+       function __construct( IContextSource $context, Title $title ) {
                $this->context = $context;
                $this->title = $title;
        }
index 0a52d75..b943b51 100644 (file)
@@ -57,7 +57,7 @@ class SpecialPage {
 
        /**
         * Current request context
-        * @var RequestContext
+        * @var IContextSource
         */
        protected $mContext;
 
@@ -226,12 +226,12 @@ class SpecialPage {
         * page, and true if it was successful.
         *
         * @param $title          Title object
-        * @param $context        RequestContext
+        * @param $context        IContextSource
         * @param $including      Bool output is being captured for use in {{special:whatever}}
         * @return Bool
         * @deprecated since 1.18 call SpecialPageFactory method directly
         */
-       public static function executePath( &$title, RequestContext &$context, $including = false ) {
+       public static function executePath( &$title, IContextSource &$context, $including = false ) {
                return SpecialPageFactory::executePath( $title, $context, $including );
        }
 
@@ -592,7 +592,7 @@ class SpecialPage {
        /**
         * Sets the context this SpecialPage is executed in
         *
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @since 1.18
         */
        public function setContext( $context ) {
@@ -602,11 +602,11 @@ class SpecialPage {
        /**
         * Gets the context this SpecialPage is executed in
         *
-        * @return RequestContext
+        * @return IContextSource
         * @since 1.18
         */
        public function getContext() {
-               if ( $this->mContext instanceof RequestContext ) {
+               if ( $this->mContext instanceof IContextSource ) {
                        return $this->mContext;
                } else {
                        wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
index 86c0bce..210c218 100644 (file)
@@ -409,12 +409,12 @@ class SpecialPageFactory {
         * page, and true if it was successful.
         *
         * @param $title          Title object
-        * @param $context        RequestContext
+        * @param $context        IContextSource
         * @param $including      Bool output is being captured for use in {{special:whatever}}
         *
         * @return bool
         */
-       public static function executePath( Title &$title, RequestContext &$context, $including = false ) {
+       public static function executePath( Title &$title, IContextSource &$context, $including = false ) {
                wfProfileIn( __METHOD__ );
 
                // @todo FIXME: Redirects broken due to this call
@@ -485,11 +485,11 @@ class SpecialPageFactory {
         * normal request, and then restores them to their previous values after.
         *
         * @param $title Title
-        * @param $context RequestContext
+        * @param $context IContextSource
         *
         * @return String: HTML fragment
         */
-       static function capturePath( Title $title, RequestContext $context ) {
+       static function capturePath( Title $title, IContextSource $context ) {
                global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgLang;
 
                // Save current globals
index ca8584b..985d951 100644 (file)
@@ -29,7 +29,7 @@ class MediaWiki {
 
        /**
         * TODO: fold $output, etc, into this
-        * @var RequestContext
+        * @var IContextSource
         */
        private $context;
 
@@ -45,7 +45,7 @@ class MediaWiki {
                return $old;
        }
 
-       public function __construct( RequestContext $context = null ) {
+       public function __construct( IContextSource $context = null ) {
                if ( !$context ) {
                        $context = RequestContext::getMain();
                }
@@ -256,10 +256,10 @@ class MediaWiki {
         *
         * @deprecated in 1.18; use Article::newFromTitle() instead
         * @param $title Title
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @return Article object
         */
-       public static function articleFromTitle( $title, RequestContext $context ) {
+       public static function articleFromTitle( $title, IContextSource $context ) {
                return Article::newFromTitle( $title, $context );
        }
 
index 4efda39..2e86f04 100644 (file)
@@ -78,9 +78,9 @@ class LogFormatter {
 
        /**
         * Replace the default context
-        * @param $context RequestContext
+        * @param $context IContextSource
         */
-       public function setContext( RequestContext $context ) {
+       public function setContext( IContextSource $context ) {
                $this->context = $context;
        }
 
index 81d4449..dc7af19 100644 (file)
@@ -7,7 +7,7 @@
  * to wrap bulk update operations.
  */
 abstract class RevDel_List extends RevisionListBase {
-       function __construct( RequestContext $context, Title $title, array $ids ) {
+       function __construct( IContextSource $context, Title $title, array $ids ) {
                parent::__construct( $context, $title );
                $this->ids = $ids;
        }
index 860fd45..0bf52ec 100644 (file)
@@ -758,7 +758,7 @@ class UploadForm extends HTMLForm {
 
        protected $mMaxFileSize = array();
 
-       public function __construct( array $options = array(), RequestContext $context = null ) {
+       public function __construct( array $options = array(), IContextSource $context = null ) {
                $this->mWatch = !empty( $options['watch'] );
                $this->mForReUpload = !empty( $options['forreupload'] );
                $this->mSessionKey = isset( $options['sessionkey'] )