resourceloader: Restrict addModuleStyles() to type=styles modules
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 29 Jun 2017 02:18:06 +0000 (19:18 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 29 Jun 2017 02:18:06 +0000 (19:18 -0700)
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
tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php

index b8f2fa5..ace8f41 100644 (file)
@@ -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 ) ) {
index 979da44..3e0d883 100644 (file)
@@ -134,7 +134,6 @@ class ResourceLoaderClientHtmlTest extends PHPUnit_Framework_TestCase {
                                'test.top',
                        ],
                        'styles' => [
-                               'test.styles.mixed',
                                'test.styles.pure',
                        ],
                        'scripts' => [