Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/150444
Change subject: Revert "Use new OutputPageScriptsForBottomQueue hook"
......................................................................
Revert "Use new OutputPageScriptsForBottomQueue hook"
After some discussion with Roan, it turns out this hook
is unnecessary. The proper solution is to use
addModuleScripts/addModuleStyles instead of a plain
addModules.
This reverts commit fa72cc05101ddffb5bbe43ef868820dcfbd9a0bf.
Change-Id: Id8bff1676cace1500639c19362fb0606fec07a17
---
M GlobalCssJs.hooks.php
M GlobalCssJs.php
M ResourceLoaderGlobalSiteModule.php
M ResourceLoaderGlobalUserModule.php
4 files changed, 30 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalCssJs
refs/changes/44/150444/1
diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php
index 95acfd2..584a9cd 100644
--- a/GlobalCssJs.hooks.php
+++ b/GlobalCssJs.hooks.php
@@ -3,12 +3,29 @@
class GlobalCssJsHooks {
/**
- * @param OutputPage $out
- * @param array $modules
+ * @param &$out OutputPage
+ * @param &$skin Skin
* @return bool
*/
- static function onOutputPageScriptsForBottomQueue( OutputPage $out,
array &$modules ) {
- $modules = array_merge( $modules, array(
'ext.globalCssJs.user', 'ext.globalCssJs.site' ) );
+ static function onBeforePageDisplay( &$out, &$skin ) {
+ global $wgGlobalCssJsConfig, $wgUseGlobalSiteCssJs;
+
+ if ( $wgUseGlobalSiteCssJs ) {
+ // Global site modules are loaded for everyone, if
enabled
+ $out->addModules( 'ext.globalCssJs.site' );
+ }
+
+ $user = $out->getUser();
+ // Only load user modules for logged in users
+ if ( $user->isAnon() ) {
+ return true;
+ }
+
+ // If we are on a different site, use a hook to allow other
extensions
+ // like CentralAuth verify that the same account exists on both
sites
+ if ( self::loadForUser( $user ) ) {
+ $out->addModules( 'ext.globalCssJs.user' );
+ }
return true;
}
diff --git a/GlobalCssJs.php b/GlobalCssJs.php
index 8a0f105..c3f00da 100644
--- a/GlobalCssJs.php
+++ b/GlobalCssJs.php
@@ -60,7 +60,7 @@
}
};
-$wgHooks['OutputPageScriptsForBottomQueue'][] =
'GlobalCssJsHooks::onOutputPageScriptsForBottomQueue';
+$wgHooks['BeforePageDisplay'][] = 'GlobalCssJsHooks::onBeforePageDisplay';
$wgHooks['ResourceLoaderRegisterModules'][] =
'GlobalCssJsHooks::onResourceLoaderRegisterModules';
$wgHooks['EditPage::showEditForm:initial'][] =
'GlobalCssJsHooks::onEditPageshowEditForminitial';
$wgHooks['GetPreferences'][] = 'GlobalCssJsHooks::onGetPreferences';
diff --git a/ResourceLoaderGlobalSiteModule.php
b/ResourceLoaderGlobalSiteModule.php
index 0f04845..b7f7501 100644
--- a/ResourceLoaderGlobalSiteModule.php
+++ b/ResourceLoaderGlobalSiteModule.php
@@ -33,12 +33,7 @@
* @return array
*/
protected function getPages( ResourceLoaderContext $context ) {
- global $wgUseSiteCss, $wgUseSiteJs, $wgUseGlobalSiteCssJs;
-
- if ( !$wgUseGlobalSiteCssJs ) {
- return array();
- }
-
+ global $wgUseSiteCss, $wgUseSiteJs;
$pages = array();
if ( $wgUseSiteJs ) {
diff --git a/ResourceLoaderGlobalUserModule.php
b/ResourceLoaderGlobalUserModule.php
index 9525a91..1d91060 100644
--- a/ResourceLoaderGlobalUserModule.php
+++ b/ResourceLoaderGlobalUserModule.php
@@ -43,18 +43,16 @@
return array();
}
- // Note, this will validate the user's name against
- // the local site rather than the target site
- $user = User::newFromName( $username );
- if ( !$user || !$user->getId() ) {
+ // Get the normalized title of the user's user page
+ // Note this validates against the local site rather than
+ // the target site.
+ $userpageTitle = Title::makeTitleSafe( NS_USER, $username );
+
+ if ( !$userpageTitle instanceof Title ) {
return array();
}
- if ( !GlobalCssJsHooks::loadForUser( $user ) ) {
- return array();
- }
-
- $userpage = $user->getUserPage()->getDBkey();
+ $userpage = $userpageTitle->getDBkey();
$pages = array();
if ( $wgAllowUserJs ) {
--
To view, visit https://gerrit.wikimedia.org/r/150444
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8bff1676cace1500639c19362fb0606fec07a17
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalCssJs
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits