There is absolutely no need for all this sort of code in the module's hook_init:

function linkimagefield_init() {
// If Content, FileField, or ImageField is not available, immediately disable Link Image Field.
$disable = FALSE;
$message = '';

if (!module_exists('content')) {
$disable = TRUE;
$message = t('The Content Creation Kit needs to be installed for it to work properly.');
}

The .info file's dependencies list guarantees that this module will not be enabled without the required modules.

CommentFileSizeAuthor
#3 linkimagefield_no_init.patch1.65 KBhefox

Comments

johnfyoung’s picture

Joachim -
Question: what does Drupal do if those dependencies are disabled or uninstalled while linkimagefield is still enabled?

Does drupal fail gracefully or does it throw up the white screen of death?

joachim’s picture

The module admin page won't let that happen; nor will drush.
If a system admin goes changing the system table by hand, then it's their problem, and it's not up to modules to account for that.

hefox’s picture

StatusFileSize
new1.65 KB

First thing I thought when viewing the .module.

Patch attached, the include modeled after how filefield includes it's filefield_widget.inc

mattcasey’s picture

+1 this patch to reduce module cruft

hefox’s picture

Status: Active » Needs review
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

sickness29’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Closed (outdated)

Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.

Everyone can apply the patch above (not tested by the maintainers, tested by the community) to their D6 projects.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.