Fix for 15e5193a19, broke in debug mode
authorCatrope <roan.kattouw@gmail.com>
Thu, 14 Jun 2012 00:46:39 +0000 (17:46 -0700)
committerCatrope <roan.kattouw@gmail.com>
Thu, 14 Jun 2012 01:06:00 +0000 (18:06 -0700)
We shouldn't be combining styles in debug mode anyways.

Change-Id: I8f0503e665df870e0940314e10185b94624869b9

includes/resourceloader/ResourceLoader.php

index 599f43e..b3d7e75 100644 (file)
@@ -713,12 +713,23 @@ class ResourceLoader {
                                // Styles
                                $styles = array();
                                if ( $context->shouldIncludeStyles() ) {
-                                       // If we are in debug mode, we'll want to return an array of URLs
+                                       // If we are in debug mode without &only= set, we'll want to return an array of URLs
                                        // See comment near shouldIncludeScripts() for more details
                                        if ( $context->getDebug() && !$context->getOnly() && $module->supportsURLLoading() ) {
                                                $styles = $module->getStyleURLsForDebug( $context );
                                        } else {
                                                $styles = $module->getStyles( $context );
+                                               // Minify CSS before embedding in mw.loader.implement call
+                                               // (unless in debug mode)
+                                               if ( !$context->getDebug() ) {
+                                                       foreach ( $styles as $media => $style ) {
+                                                               if ( is_string( $style ) ) {
+                                                                       $styles[$media] = $this->filter( 'minify-css', $style );
+                                                               }
+                                                       }
+                                               }
+                                               // Combine styles for all media types
+                                               $styles = array( '' => self::makeCombinedStyles( $styles ) );
                                        }
                                }
 
@@ -737,25 +748,16 @@ class ResourceLoader {
                                                }
                                                break;
                                        case 'styles':
-                                               $out .= self::makeCombinedStyles( $styles );
+                                               $out .= $styles['']; // Code above has set $styles['']
                                                break;
                                        case 'messages':
                                                $out .= self::makeMessageSetScript( new XmlJsCode( $messagesBlob ) );
                                                break;
                                        default:
-                                               // Minify CSS before embedding in mw.loader.implement call
-                                               // (unless in debug mode)
-                                               if ( !$context->getDebug() ) {
-                                                       foreach ( $styles as $media => $style ) {
-                                                               if ( is_string( $style ) ) {
-                                                                       $styles[$media] = $this->filter( 'minify-css', $style );
-                                                               }
-                                                       }
-                                               }
                                                $out .= self::makeLoaderImplementScript(
                                                        $name,
                                                        $scripts,
-                                                       self::makeCombinedStyles( $styles ),
+                                                       $styles,
                                                        new XmlJsCode( $messagesBlob )
                                                );
                                                break;