resourceloader: Move applyFilter() stats back to filter()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 30 Jun 2015 01:12:40 +0000 (02:12 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 30 Jun 2015 01:12:40 +0000 (02:12 +0100)
Follow-up b88e88b, which converted the count stats to include
timing information but incidentally moved the gathering point
inside the method, which meant it now also applied to uncached
minifications from logged-in user html views (called from one
branch higher in the filter method).

This should reset the 'resourceloader_cache.minify-js.miss.count'
back to normal levels.

Change-Id: I7761242f016e9026f5012352ec2f7297c1753f25

includes/resourceloader/ResourceLoader.php

index 3d49d94..04b6fec 100644 (file)
@@ -215,7 +215,12 @@ class ResourceLoader implements LoggerAwareInterface {
                        }
                        $result = '';
                        try {
+                               $stats = RequestContext::getMain()->getStats();
+                               $statStart = microtime( true );
+
                                $result = $this->applyFilter( $filter, $data );
+
+                               $stats->timing( "resourceloader_cache.$filter.miss", microtime( true ) - $statStart );
                                if ( $options['cacheReport'] ) {
                                        $result .= "\n/* cache key: $key */";
                                }
@@ -233,22 +238,16 @@ class ResourceLoader implements LoggerAwareInterface {
        }
 
        private function applyFilter( $filter, $data ) {
-               $stats = RequestContext::getMain()->getStats();
-               $statStart = microtime( true );
-
                switch ( $filter ) {
                        case 'minify-js':
-                               $data = JavaScriptMinifier::minify( $data,
+                               return JavaScriptMinifier::minify( $data,
                                        $this->config->get( 'ResourceLoaderMinifierStatementsOnOwnLine' ),
                                        $this->config->get( 'ResourceLoaderMinifierMaxLineLength' )
                                );
-                               break;
                        case 'minify-css':
-                               $data = CSSMin::minify( $data );
-                               break;
+                               return CSSMin::minify( $data );
                }
 
-               $stats->timing( "resourceloader_cache.$filter.miss", microtime( true ) - $statStart );
                return $data;
        }