Merge "Allow putting the app ID in the password for bot passwords"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderContext.php
index 8e0239a..30fe3ae 100644 (file)
@@ -91,8 +91,8 @@ class ResourceLoaderContext {
 
        /**
         * Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux to
-        * an array of module names like array( 'jquery.foo', 'jquery.bar',
-        * 'jquery.ui.baz', 'jquery.ui.quux' )
+        * an array of module names like [ 'jquery.foo', 'jquery.bar',
+        * 'jquery.ui.baz', 'jquery.ui.quux' ]
         * @param string $modules Packed module name list
         * @return array Array of module names
         */
@@ -113,7 +113,7 @@ class ResourceLoaderContext {
                                } else {
                                        // We have a prefix and a bunch of suffixes
                                        $prefix = substr( $group, 0, $pos ); // 'foo'
-                                       $suffixes = explode( ',', substr( $group, $pos + 1 ) ); // array( 'bar', 'baz' )
+                                       $suffixes = explode( ',', substr( $group, $pos + 1 ) ); // [ 'bar', 'baz' ]
                                        foreach ( $suffixes as $suffix ) {
                                                $retval[] = "$prefix.$suffix";
                                        }
@@ -175,8 +175,7 @@ class ResourceLoaderContext {
                        // Stricter version of RequestContext::sanitizeLangCode()
                        if ( !Language::isValidBuiltInCode( $lang ) ) {
                                wfDebug( "Invalid user language code\n" );
-                               global $wgLanguageCode;
-                               $lang = $wgLanguageCode;
+                               $lang = $this->getResourceLoader()->getConfig()->get( 'LanguageCode' );
                        }
                        $this->language = $lang;
                }
@@ -227,15 +226,17 @@ class ResourceLoaderContext {
         * Get the possibly-cached User object for the specified username
         *
         * @since 1.25
-        * @return User|bool false if a valid object cannot be created
+        * @return User
         */
        public function getUserObj() {
                if ( $this->userObj === null ) {
                        $username = $this->getUser();
                        if ( $username ) {
-                               $this->userObj = User::newFromName( $username );
+                               // Use provided username if valid, fallback to anonymous user
+                               $this->userObj = User::newFromName( $username ) ?: new User;
                        } else {
-                               $this->userObj = new User; // Anonymous user
+                               // Anonymous user
+                               $this->userObj = new User;
                        }
                }
 
@@ -258,7 +259,7 @@ class ResourceLoaderContext {
 
        /**
         * @see ResourceLoaderModule::getVersionHash
-        * @see OutputPage::makeResourceLoaderLink
+        * @see ResourceLoaderClientHtml::makeLoad
         * @return string|null
         */
        public function getVersion() {