Unroll array_map in ResourceLoaderFileModule::readStyleFiles
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 30 Jan 2014 18:39:51 +0000 (19:39 +0100)
committerSanthosh <santhosh.thottingal@gmail.com>
Thu, 13 Feb 2014 06:27:17 +0000 (06:27 +0000)
ResourceLoaderFileModule::readStyleFile can throw exceptions which
produces warnings when using array_map.

Produces useful stacktraces when there are issues with style file like LESS compilation errors

Bug: 47844
Bug: 59858
Change-Id: I7c48b2c94752eee81f0eeb8e00d1f2b526d80dfc

includes/resourceloader/ResourceLoaderFileModule.php

index eaff86f..23d5825 100644 (file)
@@ -674,6 +674,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *
         * @param bool $flip
         *
+        * @throws MWException
         * @return array: List of concatenated and remapped CSS data from $styles,
         *     keyed by media type
         */
@@ -683,14 +684,11 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                }
                foreach ( $styles as $media => $files ) {
                        $uniqueFiles = array_unique( $files );
-                       $styles[$media] = implode(
-                               "\n",
-                               array_map(
-                                       array( $this, 'readStyleFile' ),
-                                       $uniqueFiles,
-                                       array_fill( 0, count( $uniqueFiles ), $flip )
-                               )
-                       );
+                       $styleFiles = array();
+                       foreach ( $uniqueFiles as $file ) {
+                               $styleFiles[] = $this->readStyleFile( $file, $flip );
+                       }
+                       $styles[$media] = implode( "\n", $styleFiles );
                }
                return $styles;
        }