From e1ebc938ce3678aca5f3b5bdec19c1e26aab8405 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 1 Mar 2015 16:25:39 +0100 Subject: [PATCH] resourceloader: Clean up UserModule to be more like UserGroupsModule Change-Id: Ic988c36c034b2862e6404bb6b6b7fe24d171fef1 --- .../ResourceLoaderUserModule.php | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderUserModule.php b/includes/resourceloader/ResourceLoaderUserModule.php index 1b6d1de07c..e2d39d0aae 100644 --- a/includes/resourceloader/ResourceLoaderUserModule.php +++ b/includes/resourceloader/ResourceLoaderUserModule.php @@ -38,36 +38,28 @@ class ResourceLoaderUserModule extends ResourceLoaderWikiModule { * @return array */ protected function getPages( ResourceLoaderContext $context ) { - $username = $context->getUser(); - - if ( $username === null ) { - return array(); - } - $allowUserJs = $this->getConfig()->get( 'AllowUserJs' ); $allowUserCss = $this->getConfig()->get( 'AllowUserCss' ); - if ( !$allowUserJs && !$allowUserCss ) { return array(); } - // Get the normalized title of the user's user page - $userpageTitle = Title::makeTitleSafe( NS_USER, $username ); - - if ( !$userpageTitle instanceof Title ) { + $user = $context->getUserObj(); + if ( !$user || $user->isAnon() ) { return array(); } - $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works + // Needed so $excludepages works + $userPage = $user->getUserPage()->getPrefixedDBkey(); $pages = array(); if ( $allowUserJs ) { - $pages["$userpage/common.js"] = array( 'type' => 'script' ); - $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' ); + $pages["$userPage/common.js"] = array( 'type' => 'script' ); + $pages["$userPage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' ); } if ( $allowUserCss ) { - $pages["$userpage/common.css"] = array( 'type' => 'style' ); - $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' ); + $pages["$userPage/common.css"] = array( 'type' => 'style' ); + $pages["$userPage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' ); } // Hack for bug 26283: if we're on a preview page for a CSS/JS page, -- 2.20.1