resourceloader: Report problematic modules in only=styles as well
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 4 May 2014 14:46:16 +0000 (16:46 +0200)
committerKrinkle <krinklemail@gmail.com>
Mon, 5 May 2014 22:37:44 +0000 (22:37 +0000)
Similar to how we do with other exceptions that we don't log on
the server but want a client to be able to debug, report modules
that were not included in the response.

Especially when debugging a load.php?only=styles request that
contains lots of different modules., there was no way of knowing
certain modules were excluded (e.g. because they aren't
registered), other than to try and remove them from the request
one by one until you're left with non-zero modules in the request
and an empty string as response body.

This change prepends a comment like the following to the response.

/*
Problematic modules: {
"foo": "missing"
}
*/

Bug: 64826
Change-Id: If5136c60ff7168dac5d6cdebd487824767c0ec16

includes/resourceloader/ResourceLoader.php

index 994812b..d723d0e 100644 (file)
@@ -904,6 +904,12 @@ class ResourceLoader {
                        if ( count( $states ) ) {
                                $out .= self::makeLoaderStateScript( $states );
                        }
+               } else {
+                       if ( count( $states ) ) {
+                               $exceptions .= self::makeComment(
+                                       'Problematic modules: ' . FormatJson::encode( $states, ResourceLoader::inDebugMode() )
+                               );
+                       }
                }
 
                if ( !$context->getDebug() ) {