Page MenuHomePhabricator

Lessc conflict with core
Closed, ResolvedPublic

Description

There is some conflict with the php parser used

$ ./composer.phar update

> ComposerHookHandler::onPreUpdate

Loading composer repositories with package information Updating dependencies (including require-dev)

- Installing less.php/less.php (v1.7.0.2)

Loading from cache

  Skipped installation of bin bin/lessc for package less.php/less.php: name conflicts with an existing file

  - Installing mediawiki/bootstrap (1.1.3)

  Downloading: 100%

Generating optimized autoload files

Warning: Ambiguous class resolution, "lessc" was found in both ".../vendor/leafo/lessphp/lessc.inc.php" and ".../vendor/less.php/less.php/lessc.inc.php", the first will be used.

Event Timeline

MarkAHershberger raised the priority of this task from to Needs Triage.
MarkAHershberger updated the task description. (Show Details)
MarkAHershberger added a project: Chameleon.
MarkAHershberger subscribed.
MarkAHershberger renamed this task from Lessc conflict with ore to Lessc conflict with core.Aug 17 2015, 6:06 PM
MarkAHershberger updated the task description. (Show Details)
MarkAHershberger set Security to None.
MarkAHershberger added a subscriber: Foxtrott.

The issue is, that less.php includes its own lessc class so it can be used as a drop in replacement for the lessc compiler. It's only recently that composer actually checks for duplicate class definitions. Anyway, it should not be a problem as long as the lessc compiler is loaded first (which seems to be the case), so it is available for MW core. The Bootstrap extension itself does not use the lessc class. In fact, before composer checked for this, Bootstrap removed the duplicate lessc class itself to ensure compatibility with MW (https://github.com/wikimedia/mediawiki-extensions-Bootstrap/blob/master/src/Hooks/SetupAfterCache.php#L113).

Foxtrott writes:

it should not be a problem as long as the lessc compiler is loaded
first (which seems to be the case), so it is available for MW
core. The Bootstrap extension itself does not use the lessc class. In
fact, before composer checked for this, Bootstrap removed the
duplicate lessc class to ansure compatibility with MW

I don't understand: why is it complaining at installation time? Is it
an old Bootstrap that causes this? If so, is there a way to force the
right version of Bootstrap?

No. There are two classes named lessc, one provided by the lessc package, the other provided by the less.php package. The lessc package was there first, but it is not maintained any more. The less.php package includes a lessc class as an adapter to make it easier to migrate away from lessc. The result is that we now have two packages both providing a lessc class.

However, we can not just dump the lessc package. First, because the lessc package is loaded by MW core which can not be undone by an extension. Second, because the two compilers are not identical. The lessc compiler is rather broken when it comes to resolving include paths. Unfortunately MW core less files are written using these quirks and do not compile with the less.php compiler.

So the only solution is to load both packages in parallel making sure that MW core uses the old compiler and the Bootstrap extension uses the new one. (Well, the other solution would be to fix the MW core less files, but I was burned when trying to get minor changes into core before, so I will not even think about trying to fix this.)

Ah... If core is using an older, unmaintained library, it makes sense to update the dependencies that core has.

I'm not sure exactly what needs to be changed, though. Is there a document somewhere that spells out how to convert from the older code to the newer code?

No, I don think so. The newer compiler was intended to be a drop-in replacement after all. But it should be rather straightforward. I started it once and it boiled down to replacing one compiler with the other and fixing the compiler errors. The problem was that MW used user-defined functions, which the new compiler did not support back then. It does now. Also, MW does not use these functions anymore, as far as I know. The rest should really mostly be cleaning up the include paths in the less files.

Foxtrott updated the task description. (Show Details)