Follow-up r84814: revert redundant summary message addition.
[lhc/web/wiklou.git] / includes / StubObject.php
index fe28f91..d1055e1 100644 (file)
@@ -62,7 +62,7 @@ class StubObject {
         * Create a new object to replace this stub object.
         */
        function _newObject() {
-               return wfCreateObject( $this->mClass, $this->mParams );
+               return MWFunction::newObj( $this->mClass, $this->mParams );
        }
 
        /**
@@ -100,7 +100,7 @@ class StubObject {
                                throw new MWException( "Unstub loop detected on call of \${$this->mGlobal}->$name from $caller\n" );
                        }
                        wfDebug( "Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}::$name from $caller\n" );
-                       $obj = $GLOBALS[$this->mGlobal] = $this->_newObject();
+                       $GLOBALS[$this->mGlobal] = $this->_newObject();
                        --$recursionLevel;
                        wfProfileOut( $fname );
                }
@@ -122,8 +122,8 @@ class StubContLang extends StubObject {
        }
 
        function _newObject() {
-               global $wgContLanguageCode;
-               $obj = Language::factory( $wgContLanguageCode );
+               global $wgLanguageCode;
+               $obj = Language::factory( $wgLanguageCode );
                $obj->initEncoding();
                $obj->initContLang();
                return $obj;
@@ -146,18 +146,20 @@ class StubUserLang extends StubObject {
        }
 
        function _newObject() {
-               global $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
+               global $wgLanguageCode, $wgRequest, $wgUser, $wgContLang;
                $code = $wgRequest->getVal( 'uselang', $wgUser->getOption( 'language' ) );
                // BCP 47 - letter case MUST NOT carry meaning
                $code = strtolower( $code );
 
                # Validate $code
-               if( empty( $code ) || !preg_match( '/^[a-z-]+$/', $code ) || ( $code === 'qqq' ) ) {
+               if( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) {
                        wfDebug( "Invalid user language code\n" );
-                       $code = $wgContLanguageCode;
+                       $code = $wgLanguageCode;
                }
 
-               if( $code === $wgContLanguageCode ) {
+               wfRunHooks( 'UserGetLanguageObject', array( $wgUser, &$code ) );
+
+               if( $code === $wgLanguageCode ) {
                        return $wgContLang;
                } else {
                        $obj = Language::factory( $code );