resourceloader: Remove redundant state assignment for styles in ClientHtml
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 5 Mar 2018 23:15:24 +0000 (15:15 -0800)
committerKrinkle <krinklemail@gmail.com>
Tue, 20 Mar 2018 23:44:41 +0000 (23:44 +0000)
The same variable index was set to the same value from two places,
one unconditionally, and two times within a conditional block after
the first one.

The second ones are a completely redundant remnant from a refactor
sometime last year.

Change-Id: Ia234d4aca398b1b365d457a439d9e449229f28fb

includes/resourceloader/ResourceLoaderClientHtml.php

index fe9e56f..a9e2f92 100644 (file)
@@ -131,9 +131,7 @@ class ResourceLoaderClientHtml {
                                // moduleName => state
                        ],
                        'general' => [],
-                       'styles' => [
-                               // moduleName
-                       ],
+                       'styles' => [],
                        'scripts' => [],
                        // Embedding for private modules
                        'embed' => [
@@ -182,20 +180,17 @@ class ResourceLoaderClientHtml {
                        }
 
                        // Stylesheet doesn't trigger mw.loader callback.
-                       // Set "ready" state to allow dependencies and avoid duplicate requests. (T87871)
+                       // Set "ready" state to allow script modules to depend on this module  (T87871).
+                       // And to avoid duplicate requests at run-time from mw.loader.
                        $data['states'][$name] = 'ready';
 
                        $group = $module->getGroup();
                        $context = $this->getContext( $group, ResourceLoaderModule::TYPE_STYLES );
-                       if ( $module->isKnownEmpty( $context ) ) {
-                               // Avoid needless request for empty module
-                               $data['states'][$name] = 'ready';
-                       } else {
+                       // Avoid needless request for empty module
+                       if ( !$module->isKnownEmpty( $context ) ) {
                                if ( $module->shouldEmbedModule( $this->context ) ) {
                                        // Embed via style element
                                        $data['embed']['styles'][] = $name;
-                                       // Avoid duplicate request from mw.loader
-                                       $data['states'][$name] = 'ready';
                                } else {
                                        // Load from load.php?only=styles via <link rel=stylesheet>
                                        $data['styles'][] = $name;