Commit 7f7bafe9 authored by Robert Rollins's avatar Robert Rollins

Issue #2127549: Fixed a protential error state in the upgrade path from v1.x.

User oskar_calvo discovered that if you update Date iCal from 1.x, but
don't also install the Libraries module, you'll get a fatal error when Date iCal
attempts to check for the iCalcreator library, because the libraries_detect()
function doesn't exist.

Now, you'll instead see an error in the site requirements.
parent cd17423a
......@@ -13,27 +13,38 @@ function date_ical_requirements($phase) {
// Ensure translations don't break at install time.
$t = get_t();
switch ($phase) {
case 'runtime':
$library = libraries_detect('iCalcreator');
if ($library && !empty($library['installed'])) {
$requirements['date_ical'] = array(
'title' => $t('Date iCal'),
'value' => $t('iCalcreator library is installed, version: @version found', array('@version' => $library['version'])),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['date_ical'] = array(
'title' => $t('Date iCal'),
'value' => $t('iCalcreator library could not be found, check the installation instructions for the Date iCal module.'),
'description' => $t('The error message was: @error<br>!error_message',
array('@error' => $library['error'], '!error_message' => $library['error message'])
),
'severity' => REQUIREMENT_ERROR,
);
}
break;
if ($phase == 'runtime') {
if (!function_exists('libraries_detect')) {
$requirements['date_ical'] = array(
'title' => $t('Date iCal'),
'value' => $t('Libraries module is not installed.'),
'description' => $t('Date iCal 2.x and above require the Libraries module. Please install it from !here.',
array('!here' => l('here', 'http://www.drupal.org/project/libraries'))
),
'severity' => REQUIREMENT_ERROR,
);
// Return immediately, since we can't even attempt to determine if iCalcreator is installed.
return $requirements;
}
$library = libraries_detect('iCalcreator');
if ($library && !empty($library['installed'])) {
$requirements['date_ical'] = array(
'title' => $t('Date iCal'),
'value' => $t('iCalcreator library is installed, version: @version found', array('@version' => $library['version'])),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['date_ical'] = array(
'title' => $t('Date iCal'),
'value' => $t('iCalcreator library could not be found, check the installation instructions for the Date iCal module.'),
'description' => $t('The error message was: @error<br>!error_message',
array('@error' => $library['error'], '!error_message' => $library['error message'])
),
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment