Page MenuHomePhabricator

mw.config wgGlobalGroups is undefined
Closed, ResolvedPublic

Description

I haven't been able to figure out why, but on actual pages (both on production wikis and in beta-labs) wgGlobalGroups is no longer being defined.

As a result, various gadgets and user scripts are no longer working properly.

wgGlobalGroups
Uncaught ReferenceError: wgGlobalGroups is not defined

It's declared in CentralAuthHooks::onMakeGlobalVariablesScript (source code).

Executing those steps from the console (deployment-bastion.wmflabs$ mwscript eval.php --wiki metawiki) results in the expected value, so something is going wrong in the front-end.

> global $wgUser;
> $wgUser = User::newFromName('Krinkle');

> $vars = array();
> CentralAuthHooks::onMakeGlobalVariablesScript( &$vars );
> return $vars;
array(1) {
  ["wgGlobalGroups"]=>
  array(2) {
    [0]=>
    string(9) "developer"
    [1]=>
    string(7) "steward"
  }
}
> return $wgHooks['MakeGlobalVariablesScript'];
array(14) {
  [0]=>
  string(45) "CentralAuthHooks::onMakeGlobalVariablesScript"
  [1]=>
  string(45) "AbuseFilterHooks::onMakeGlobalVariablesScript"
  [2]=>
  string(42) "WikiEditorHooks::makeGlobalVariablesScript"
  [3]=>
  string(48) "MultimediaViewerHooks::makeGlobalVariablesScript"
  [4]=>
  string(46) "VisualEditorHooks::onMakeGlobalVariablesScript"
  [5]=>
  string(41) "Gather\Hooks::onMakeGlobalVariablesScript"
  [6]=>
  string(25) "TranslateHooks::addConfig"
  [7]=>
  string(36) "EchoHooks::makeGlobalVariablesScript"
  [8]=>
  string(44) "CodeEditorHooks::onMakeGlobalVariablesScript"
  [9]=>
  string(49) "WikimediaEventsHooks::onMakeGlobalVariablesScript"
  [10]=>
  string(44) "UniversalLanguageSelectorHooks::addVariables"
  [11]=>
  array(1) {
    [0]=>
    string(46) "BetaFeaturesHooks::onMakeGlobalVariablesScript"
  }
  [12]=>
  string(27) "efCategoryTreeGetConfigVars"
  [13]=>
  string(23) "efCentralNoticeDefaults"
}

Event Timeline

Krinkle raised the priority of this task from to Unbreak Now!.
Krinkle updated the task description. (Show Details)
Krinkle added a subscriber: Krinkle.
Krinkle set Security to None.

I've instrumented OutputPage.php and CentralAuthHook on beta with some debug logging.

CentralAuthHooks::onMakeGlobalVariablesScript does indeed get run, and the function works as expected (it reacher the inner $groups['wgGlobalGroups'] assignment).

--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1294,6 +1294,7 @@ class CentralAuthHooks {
                if ( !$wgUser->isAnon() ) {
                        $centralUser = CentralAuthUser::getInstance( $wgUser );
                        if ( $centralUser->exists() && $centralUser->isAttached() ) {
+                               wfDebugLog( 'CentralAuthVerbose', __METHOD__ . ' Adding wgGlobalGroups' );
                                $groups['wgGlobalGroups'] = $centralUser->getGlobalGroups();
                        }
                }

2015-04-28T04:09:05.889Z mediawiki deployment-mediawiki01 CentralAuthHooks::onMakeGlobalVariablesScript Adding wgGloba...

In OutputPage#getJSVars, right after Hooks::run the wgGlobalGroups key is not in $vars

                Hooks::run( 'MakeGlobalVariablesScript', array( &$vars, $this ) );
+              wfDebugLog( 'CentralAuthVerbose', __METHOD__ . join( ', ',array_keys( $vars ) ) );

2015-04-28T04:09:05.889Z mediawiki deployment-mediawiki01 OutputPage::getJSVars
wgCanonicalNamespace, wgCanonicalSpecialPageName, wgNamespaceNumber, wgPageName, wgTitle, wgCurRevisionId, wgRevisionId, wgArticleId, wgIsArticle, wgIsRedirect, wgAction, wgUserName, wgUserGroups, wgCategories, wgBreakFrames, wgPageContentLanguage, wgPageContentModel, wgSeparatorTransformTable, wgDigitTransformTable, wgDefaultDateFormat, wgMonthNames, wgMonthNamesShort, wgRelevantPageName, wgRelevantArticleId, wgUserId, wgUserEditCount, wgUserRegistration, wgUserNewMsgRevisionId, wgIsProbablyEditable, wgWikiEditorEnabledModules, wgMediaViewerOnClick, wgMediaViewerEnabledByDefault, wgVisualEditor, wgGatherShouldShowTutorial, wgEchoOverlayConfiguration, wgEchoHelpPage, wgEchoConfig, wgPoweredByHHVM, wgULSAcceptLanguageList, wgULSCurrentAutonym, wgBetaFeaturesFeatures, wgCategoryTreePageCategoryOptions, wgNoticeProject, wgNoticeUserData

The default core keys (e.g. wgIsProbablyEditable), and keys from other extensions (e.g. wgWikiEditorEnabledModules), are fine.

What's going on?

Change 207019 had a related patch set uploaded (by Krinkle):
hooks: Fix missing '&' in onMakeGlobalVariablesScript signature

https://gerrit.wikimedia.org/r/207019

Change 207019 merged by jenkins-bot:
hooks: Fix missing '&' in onMakeGlobalVariablesScript signature

https://gerrit.wikimedia.org/r/207019

Change 207021 had a related patch set uploaded (by Krinkle):
hooks: Fix missing '&' in onMakeGlobalVariablesScript signature

https://gerrit.wikimedia.org/r/207021

Change 207023 had a related patch set uploaded (by Krinkle):
hooks: Fix missing '&' in onMakeGlobalVariablesScript signature

https://gerrit.wikimedia.org/r/207023

Change 207021 merged by jenkins-bot:
hooks: Fix missing '&' in onMakeGlobalVariablesScript signature

https://gerrit.wikimedia.org/r/207021

Change 207023 merged by jenkins-bot:
hooks: Fix missing '&' in onMakeGlobalVariablesScript signature

https://gerrit.wikimedia.org/r/207023

hoo removed a project: Patch-For-Review.