X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderContext.php;h=79b71df18bcca65641912dcfe74e5a2b9461f2d1;hb=2686727565a3eb1a9afff53b7c8b0d6b1106fb50;hp=8e0239a530003fdd5d494d05637cead272a28929;hpb=7f91193ef37d534949950c980416b5a921cd5d79;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderContext.php b/includes/resourceloader/ResourceLoaderContext.php index 8e0239a530..79b71df18b 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"; } @@ -227,15 +227,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 +260,7 @@ class ResourceLoaderContext { /** * @see ResourceLoaderModule::getVersionHash - * @see OutputPage::makeResourceLoaderLink + * @see ResourceLoaderClientHtml::makeLoad * @return string|null */ public function getVersion() {