* Wont work
[lhc/web/wiklou.git] / includes / StubObject.php
index 4068c31..a9a6bde 100644 (file)
@@ -24,7 +24,7 @@ class StubObject {
        }
 
        static function isRealObject( $obj ) {
-               return is_object( $obj ) && !is_a( $obj, 'StubObject' );
+               return is_object( $obj ) && !($obj instanceof StubObject);
        }
 
        function _call( $name, $args ) {
@@ -35,7 +35,7 @@ class StubObject {
        function _newObject() {
                return wfCreateObject( $this->mClass, $this->mParams );
        }
-       
+
        function __call( $name, $args ) {
                return $this->_call( $name, $args );
        }
@@ -89,20 +89,19 @@ class StubUserLang extends StubObject {
 
        function _newObject() {
                global $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
-               $code = $wgRequest->getVal('uselang', '');
-               if ($code == '')
-                       $code = $wgUser->getOption('language');
+               $code = $wgRequest->getVal('uselang', $wgUser->getOption('language') );
 
                // if variant is explicitely selected, use it instead the one from wgUser
                // see bug #7605
                if($wgContLang->hasVariants()){
-                       $variant = $wgContLang->getPreferredVariant(false);
+                       $variant = $wgContLang->getPreferredVariant();
                        if($variant != $wgContLanguageCode)
                                $code = $variant;
                }        
 
                # Validate $code
-               if( empty( $code ) || !preg_match( '/^[a-z]+(-[a-z]+)?$/', $code ) ) {
+               if( empty( $code ) || !preg_match( '/^[a-z-]+$/', $code ) ) {
+                       wfDebug( "Invalid user language code\n" );
                        $code = $wgContLanguageCode;
                }
 
@@ -135,4 +134,4 @@ class StubUser extends StubObject {
        }
 }
 
-?>
+