The following implementation of hook_requirements() depends on drupal_load(). When using a custom profile in a drupal installation, drupal_load() will always return false while the installer checks during the Verify requirements stage.
function formatted_number_requirements($phase) {
if ($phase == 'install') {
$requirements = array();
// Ensure translations don't break at install time
$t = get_t();
drupal_load('module', 'format_number');
if (!function_exists('format_number_get_options')) {
$requirements['format_number'] = array(
'title' => $t('Format Number API'),
'description' => $t('%module-name requires, at least, version 6.x-1.1 of the <a href="@format-number">Format Number API</a> module.', array(
'%module-name' => $t('Formatter Number CCK'),
'@format-number' => 'http://drupal.org/project/format_number',
)),
'value' => $t('version 6.x-1.0'),
'severity' => REQUIREMENT_ERROR,
);
}
return $requirements;
}
}
The problem is that drupal_load() is returning false during installation even if the requirement is present. A possible solution is to use runtime phase instead of install as the module dependency is already at the module's .info.
Comments
Comment #1
silvio commentedComment #2
silvio commentedSorry, corrected patch attached.
Comment #3
markus_petrux commentedThe problem is that hook_requirements('runtime') does not cover the need to prevent the use of the module, so we'll get errors when code depending on the correct version of format_number is executed. What we want here is prevent the installation of this module if the correct version of format_number is not installed.
Why drupal_load() returns FALSE when invoked during the installation of a custom profile? That looks like a bug in Drupal (or the custom profile) to me.
Comment #4
markus_petrux commented