tags:

views:

8

answers:

1

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?

A: 

You can force drupal to load the module (it's common practice for CCK modules for example).

Example:

function example_install() {
    drupal_load('module', 'content');
    content_notify('install', 'example');
}

In the example, drupal_load loads the "content" module first, then content_notify is an example of function that can only be used when the content module is available.

So if the drupal_load call returns FALSE, you can detect that the module is missing and notify the user.

wildpeaks