Merge "API: Overhaul ApiResult, make format=xml not throw, and add json formatversion"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderFileModule.php
index a46c931..671098e 100644 (file)
@@ -174,7 +174,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *     to $wgResourceBasePath
         *
         * Below is a description for the $options array:
-        * @throws MWException
+        * @throws InvalidArgumentException
         * @par Construction options:
         * @code
         *     array(
@@ -255,14 +255,14 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                case 'skinScripts':
                                case 'skinStyles':
                                        if ( !is_array( $option ) ) {
-                                               throw new MWException(
+                                               throw new InvalidArgumentException(
                                                        "Invalid collated file path list error. " .
                                                        "'$option' given, array expected."
                                                );
                                        }
                                        foreach ( $option as $key => $value ) {
                                                if ( !is_string( $key ) ) {
-                                                       throw new MWException(
+                                                       throw new InvalidArgumentException(
                                                                "Invalid collated file path list key error. " .
                                                                "'$key' given, string expected."
                                                        );
@@ -573,6 +573,10 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                $files = array_map( array( $this, 'getLocalPath' ), $files );
                // File deps need to be treated separately because they're already prefixed
                $files = array_merge( $files, $this->getFileDependencies( $context->getSkin() ) );
+               // Filter out any duplicates from getFileDependencies() and others.
+               // Most commonly introduced by compileLessFile(), which always includes the
+               // entry point Less file we already know about.
+               $files = array_values( array_unique( $files ) );
 
                // If a module is nothing but a list of dependencies, we need to avoid
                // giving max() an empty array