Download & Extend

no need to check dependencies in hook_init

Project:Link Image Field
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

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.

Comments

#1

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?

#2

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.

#3

First thing I thought when viewing the .module.

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

AttachmentSize
linkimagefield_no_init.patch 1.65 KB

#4

+1 this patch to reduce module cruft

#5

Status:active» needs review
nobody click here