From ed28e106e366fea109b85413fc9e23b88724d283 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 28 Jun 2017 19:18:06 -0700 Subject: [PATCH] resourceloader: Restrict addModuleStyles() to type=styles modules If a type=general module is enqueued, don't try to load it as a stylesheet. * Per a464d1d41d69f12fe, state tracking is already disabled for these loads (as otherwise we wrongly claim state=ready, when in fact only the styles and not the scripts were loaded). * The warning was added in a464d1d41d69f12fe. * Default install (tested in Vagrant), Wikimedia Beta cluster, and Wikimedia production have seen zero violations of this warning in the past 7 days. Raise severity to ERROR and add the 'continue' statement so that these are now not loaded at all. Bug: T92459 Change-Id: I211d56ac2df479ebf5b98667c613ecf81489539b --- includes/resourceloader/ResourceLoaderClientHtml.php | 11 ++++++----- .../resourceloader/ResourceLoaderClientHtmlTest.php | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderClientHtml.php b/includes/resourceloader/ResourceLoaderClientHtml.php index b8f2fa53e1..ace8f4126a 100644 --- a/includes/resourceloader/ResourceLoaderClientHtml.php +++ b/includes/resourceloader/ResourceLoaderClientHtml.php @@ -170,15 +170,16 @@ class ResourceLoaderClientHtml { if ( $module->getType() !== ResourceLoaderModule::LOAD_STYLES ) { $logger = $rl->getLogger(); - $logger->warning( 'Unexpected general module "{module}" in styles queue.', [ + $logger->error( 'Unexpected general module "{module}" in styles queue.', [ 'module' => $name, ] ); - } else { - // Stylesheet doesn't trigger mw.loader callback. - // Set "ready" state to allow dependencies and avoid duplicate requests. (T87871) - $data['states'][$name] = 'ready'; + continue; } + // Stylesheet doesn't trigger mw.loader callback. + // Set "ready" state to allow dependencies and avoid duplicate requests. (T87871) + $data['states'][$name] = 'ready'; + $group = $module->getGroup(); $context = $this->getContext( $group, ResourceLoaderModule::TYPE_STYLES ); if ( $module->isKnownEmpty( $context ) ) { diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 979da44245..3e0d883c60 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -134,7 +134,6 @@ class ResourceLoaderClientHtmlTest extends PHPUnit_Framework_TestCase { 'test.top', ], 'styles' => [ - 'test.styles.mixed', 'test.styles.pure', ], 'scripts' => [ -- 2.20.1