Fix Bug 33384 - database drivers cannot be provided by extension
[lhc/web/wiklou.git] / includes / StubObject.php
index f2a8b33..647ad92 100644 (file)
@@ -60,6 +60,7 @@ class StubObject {
 
        /**
         * Create a new object to replace this stub object.
+        * @return object
         */
        function _newObject() {
                return MWFunction::newObj( $this->mClass, $this->mParams );
@@ -89,9 +90,10 @@ class StubObject {
        function _unstub( $name = '_unstub', $level = 2 ) {
                static $recursionLevel = 0;
 
-               if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) )
+               if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) ) {
                        return $GLOBALS[$this->mGlobal]; // already unstubbed.
-               
+               }
+
                if ( get_class( $GLOBALS[$this->mGlobal] ) != $this->mClass ) {
                        $fname = __METHOD__.'-'.$this->mGlobal;
                        wfProfileIn( $fname );
@@ -110,10 +112,13 @@ class StubObject {
 /**
  * Stub object for the content language of this wiki. This object have to be in
  * $wgContLang global.
+ *
+ * @deprecated since 1.18
  */
 class StubContLang extends StubObject {
 
        function __construct() {
+               wfDeprecated( __CLASS__, '1.18' );
                parent::__construct( 'wgContLang' );
        }
 
@@ -121,6 +126,9 @@ class StubContLang extends StubObject {
                return $this->_call( $name, $args );
        }
 
+       /**
+        * @return Language
+        */
        function _newObject() {
                global $wgLanguageCode;
                $obj = Language::factory( $wgLanguageCode );
@@ -131,44 +139,24 @@ class StubContLang extends StubObject {
 }
 
 /**
- * Stub object for the $wg globals replaced by RequestContext
+ * Stub object for the user language. It depends of the user preferences and
+ * "uselang" parameter that can be passed to index.php. This object have to be
+ * in $wgLang global.
  */
-class StubRequestContext extends StubObject {
-       
-       private $method = null;
-       
-       function __construct( $global, $method ) {
-               parent::__construct( $global, 'RequestContext' );
-               $this->method = $method;
-       }
-       
-       function __call( $name, $args ) {
-               return $this->_call( $name, $args );
-       }
-       
-       function __get( $name ) {
-               // __get doesn't seam to play nice with _unstub
-               return RequestContext::getMain()->{$this->method}()->{$name};
-       }
-
-       function __set( $name, $val ) {
-               // __set doesn't seam to play nice with _unstub
-               RequestContext::getMain()->{$this->method}()->{$name} = $val;
-       }
+class StubUserLang extends StubObject {
 
-       function __isset( $name ) {
-               // __isset doesn't seam to play nice with _unstub
-               return isset( RequestContext::getMain()->{$this->method}()->{$name} );
+       function __construct() {
+               parent::__construct( 'wgLang' );
        }
 
-       function __unset( $name ) {
-               // __unset doesn't seam to play nice with _unstub
-               unset( RequestContext::getMain()->{$this->method}()->{$name} );
+       function __call( $name, $args ) {
+               return $this->_call( $name, $args );
        }
 
+       /**
+        * @return Language
+        */
        function _newObject() {
-               return RequestContext::getMain()->{$this->method}();
+               return RequestContext::getMain()->getLanguage();
        }
-       
 }
-