From dbbc3c2329757987f71e63ce83b17541e61ed0f3 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 13 Sep 2016 21:54:57 -0700 Subject: [PATCH] OutputPage: Don't set 'user' module state if filtered out On pages where the 'user' module is filtered out (e.g. on Special:Preferences) it would export state 'loading' (or state 'ready') eventhough the actual call to makeResourceLoader() later in getBottomScripts() would be a no-op due to filtering. This would cause either an indefinite state of "loading" or a state "ready" that wasn't true. This restores status quo as it was before 80e5b160 and 3e7a50d5f. Test plan: * Logged-in with non-empty user page common.js. * View Special:Preferences. * Verify in source code, or via mw.loader.getState('user') that it has state "registered" (the default initial state) and not state "loading" or "ready". Change-Id: I9b360d7e12703bddb80793aef47296fd63032c3d --- includes/OutputPage.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index d9230b0a66..4c4fb1c6e4 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2726,12 +2726,17 @@ class OutputPage extends ContextSource { ); $this->rlExemptStyleModules = $exemptGroups; - // Manually handled by getBottomScripts() - $userModule = $rl->getModule( 'user' ); - $userState = $userModule->isKnownEmpty( $context ) && !$this->isUserJsPreview() - ? 'ready' - : 'loading'; - $this->rlUserModuleState = $exemptStates['user'] = $userState; + $isUserModuleFiltered = !$this->filterModules( [ 'user' ] ); + // If this page filters out 'user', makeResourceLoaderLink will drop it. + // Avoid indefinite "loading" state or untrue "ready" state (T145368). + if ( !$isUserModuleFiltered ) { + // Manually handled by getBottomScripts() + $userModule = $rl->getModule( 'user' ); + $userState = $userModule->isKnownEmpty( $context ) && !$this->isUserJsPreview() + ? 'ready' + : 'loading'; + $this->rlUserModuleState = $exemptStates['user'] = $userState; + } $rlClient = new ResourceLoaderClientHtml( $context, $this->getTarget() ); $rlClient->setConfig( $this->getJSVars() ); -- 2.20.1