Hello all,

Users of the htmlpurifier library have been clamoring for Libraries API support for some time, see #708266: Decouple Location of htmlpurifier Library with Libraries API and #602530: Use Common Repository for Libraries. However, in the process of testing a patch supplied by one of these users, I noticed the following *awesome* behavior:

  • First of all, if I used a naive patch that just cuts over to the new API, and the user doesn't have Libraries API installed, things just break with fatal errors
  • Second of all, if I fix up the code to be robust when the Libraries API is not installed, the user can't *disable* the module now, since Drupal's interface claims that Libraries API isn't installed, so you can't change the status module. So it's stuck.

How do I make this not be a problem?

Comments

wik’s picture

subscribing

drewish’s picture

hook_requirements() might be one way of doing it.

tstoeckler’s picture

That's a bad case of #228860: Upgrading a module with a newly added dependencies breaks things badly (Drupal 7 core issue).
See the patch in there for some code you might be able to use.

sun’s picture

http://drupal.org/project/phpmailer 3.x implements optional support for Libraries API. It basically boils down to:

- no module dependency
- a private wrapper function that either leverages Libraries API or falls back to custom/old-school library location.

I'm not saying that its fallback handling is perfect, but it may provide some clues.

ezyang’s picture

Status: Active » Fixed

The procedure in phpmailer is what I'm going to go with. With any luck Drupal will fix the underlying issue!

irakli’s picture

In case of libraries it probably is not worth/the best option, but in general, another way of introducing a dependency in a popular module, for existing installations:

function mymodule_update_6007() {
  $ret = array();
  $newdependency = "mickymouse";

  // We introduced dependency on "mickymouse" module
  if (!module_exists($newdependency)) {
    $filename = drupal_get_filename('module', $newdependency);
    
    if (!empty($filename)) {
      module_enable(array($newdependency));
    }
    else {
      $ret['#abort'] = array('success' => FALSE, 'query' => "You need to install $newdependency module before you can run this update.");
      return $ret;    
    }         
  }

//...... any other updates you may have ...

}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.