So I understand this is *really* an edge case. I'm more interested in having some information, rather than actually getting it fixed (I can patch it and manage it myself; it must be very rare).

I have a custom installation profile, which includes Libraries API and XAutoload. When installing through the UI (via /install.php), it works fine. However, when installing via Drush (typically the case when using Aegir), it throws a Fatal Error. I tracked it down to Drupal\xautoload\Discovery\ComposerJson::writeToAdapter(). What happens is that a library has some functions, which are included via the composer.json autoload.files directive (library in question: https://github.com/fruux/sabre-xml/). XAutoload, during an install via Drush, actually requires the file containing these functions twice, resulting in the Fatal Error.

A simple fix is changing the require call to a require_once. The installation now passes without problem. But what I'm worried about is: why use require in the first place? Is there any reason for this? If I patch it (example patch will follow soon), will it break my installs down the road?

Thanks for the help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wadmiraal created an issue. See original summary.

wadmiraal’s picture

donquixote’s picture

Interesting.

Can you upload or post the part of the install profile that has the xautoload / libraries integration?
Maybe it is enough to just post a code snippet, I don't know.

I remember that the composer.json integration is somewhat limited when it comes to stuff other than regular psr-4 or psr-0 class loading.

E.g. a natural problem with the 'files' integration is caching.
The general idea is that in a request where the cache is "hot" with a complete class map, xautoload can skip the entire "bootstrap" and does not have to scan any composer.json files or do other possibly expensive things.
But the include statements cannot be cached.

Now I don't know if this is really your issue. I think for you the problem might be something else.
The 'require' might be just copied from composer.
I don't know why this now happens 2x in a request. Stack trace welcome :)

In general, I think the better option is to use composer_manager for more advanced Composer integration.
I think the original motivation to support this in xautoload with libraries was "because I can".

And indeed I want to understand what is going on before I accept a patch.

SocialNicheGuru’s picture

Status: Active » Needs review