I have a new version of a Drupal 6 module. In the new version, I have added a new dependency in the .info file to a views utility module I’ve created called lib_views.
However, lib_views may not be enabled when my module is upgraded. If it’s not, then upgrading my module causes an irretrievable crash, because views fires a hook that invokes a function in my un-enabled lib_views module.
Is there any safe way to add a new dependency to an existing Drupal module that can prevent this?
You can force drupal to load the module (it’s common practice for CCK modules for example).
Example:
In the example,
drupal_loadloads the “content” module first, thencontent_notifyis an example of function that can only be used when the content module is available.So if the
drupal_loadcall returnsFALSE, you can detect that the module is missing and notify the user.