X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderContext.php;h=30fe3ae4ac258fb068a287c2b500437ff0d69eae;hb=fc7d715b4b5adedd0ae3e9e6f969c89e19d460eb;hp=8e0239a530003fdd5d494d05637cead272a28929;hpb=90f599a5a2b46794a3002ee2f2563fc456a2fddb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderContext.php b/includes/resourceloader/ResourceLoaderContext.php index 8e0239a530..30fe3ae4ac 100644 --- a/includes/resourceloader/ResourceLoaderContext.php +++ b/includes/resourceloader/ResourceLoaderContext.php @@ -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() {