function mail_logger_update_7002 in Mail Logger 7
Verify correct schema for 'ipaddr' column.
File
- ./
mail_logger.install, line 166 - Install, update and uninstall functions for the mail_logger module.
Code
function mail_logger_update_7002() {
// mail_logger_update_7001() initially had an error that could lead to a
// corrupt schema and NULL values in the ipaddr column. These problems can
// persist even after the user runs the corrected version of update 7001, so
// we use this update hook to detect/fix those cases.
// @see https://www.drupal.org/node/2668458
$current_schema = drupal_get_schema('mail_logger');
// First change any NULL ipaddr values to our intended empty value.
$updated = db_update('mail_logger')
->fields(array(
'ipaddr' => '',
))
->condition('ipaddr', NULL)
->execute();
// If NULL values were found and corrected this in an indicator that the
// schema spec for the ipaddr column may also be in a corrupt state, so we
// refresh its definition.
if ($updated) {
db_change_field('mail_logger', 'ipaddr', 'ipaddr', $current_schema['fields']['ipaddr']);
return t('The Mail_logger "ipaddr" field has been verified.');
}
return t('The Mail_logger "ipaddr" field did not require verification.');
}