The libraries_load() function always stores the result of its call to libraries_detect() into the DB cache, but I really don't think that it should do so when detection fails. This causes a very bad user experience when they fail to install a library correctly the first time, then fix their install and try again. Trying again will continue to show that the library isn't installed, even though it is, because the failure to detect the library has been cached.

I've included a patch for this change.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

Category: Bug report » Feature request
Status: Needs review » Closed (won't fix)

Hmm... I totally get the notion of that. The current behavior really is suboptimal.

However, the current behavior allows for optional integration of libraries without any performance hit. I.e. I can just do

if ($library = libraries_load('foo') && $library['loaded']) {
  // Some progressive enhancement of my module.
}

With your patch that would mean that the file is being detected (including possible parsing some file for version information) on each request. I think the proper way to solve this would be to provide a proper UI with steps on how to install a particular library that also gives appropriate feedback. On that page we could then clear the library cache on each request.

Therefore, closing this ticket, sadly.

Please do re-open if you have other ideas on how to solve this while allowing for both use-cases. And thanks a lot for your input, much appreciated.