From: Timo Tijhof Date: Thu, 29 Jun 2017 02:18:06 +0000 (-0700) Subject: resourceloader: Restrict addModuleStyles() to type=styles modules X-Git-Tag: 1.31.0-rc.0~2836^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=ed28e106e366fea109b85413fc9e23b88724d283;p=lhc%2Fweb%2Fwiklou.git 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 --- 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' => [