Page MenuHomePhabricator

Difficult to debug LESS compilation errors
Closed, ResolvedPublic


If there is a compilation error with the less files, the only exception we get is

Warning: array_map(): An error occurred while invoking the map callback in /home/santhosh/dev/wiki/core/includes/resourceloader/ResourceLoaderFileModule.php

This is not helpful. Because array maps cannot properly report errors from callbacks.

Roan already reported this issue at PHP with a patch. but not accepted at upstream.

Can't we modify the code in readStyleFiles of ResourceLoaderFileModule a bit so that we get sensible stack trace and saves time in debugging?

instead of array map, it can be something like

$style= "";
foreach ( $files as $file ) {

$style = $style . "\n".  $this->readStyleFile( $file,  $flip );

$styles[$media] = $style;

What I expect is a helpful error message like:

exception 'Exception' with message '.mw-ui-one-third is undefined: failed at .mw-ui-one-third; /home/santhosh/dev/wiki/ContentTranslation/modules/base/styles/base.less on line 27' in /home/santhosh/dev/wiki/core/includes/libs/

Version: 1.23.0
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:32 AM
bzimport set Reference to bz59858.
bzimport added a subscriber: Unknown Object (MLST).

Change 109956 had a related patch set uploaded by Santhosh:
Unroll array_map in ResourceLoaderFileModule::readStyleFiles

Change 106486 abandoned by Santhosh:
Avoid array_map to get useful debug information about LESS errors

Abandoning in favor of I7c48b2c94752eee81f0eeb8e00d1f2b526d80dfc

Same approach is used in that patch

Change 109956 merged by jenkins-bot:
Unroll array_map in ResourceLoaderFileModule::readStyleFiles