diff --git a/link.install b/link.install index 7b1b4c7..653de4d 100644 --- a/link.install +++ b/link.install @@ -105,7 +105,7 @@ function link_update_6001() { */ function link_update_6002() { $ret = array(); - + // Build a list of fields that need updating. $update_fields = array(); foreach (content_types_install() as $type_name => $fields) { @@ -116,7 +116,7 @@ function link_update_6002() { } } } - + // Update each field's storage to match the current definition. foreach ($update_fields as $field) { $db_info = content_database_info($field); @@ -130,9 +130,39 @@ function link_update_6002() { } } } - + // Let CCK re-associate link fields with Link module and activate the fields. content_associate_fields('link'); - + return $ret; -} \ No newline at end of file +} + +/** + * This update changes all url fields from type varchar(2048) to type text. + * See https://www.drupal.org/node/838902#comment-8915761 and following + */ +function link_update_6003() { + $ret = array(); + + // Load the CCK API. + module_load_include('crud.inc', 'content', 'includes/content'); + // Build a list of fields that need updating. + $update_fields = array(); + foreach (content_types_install() as $type_name => $fields) { + foreach ($fields as $field) { + if ($field['type'] == 'link') { + // We only process a given field once. + $update_fields[$field['field_name']] = $field; + } + } + } + // Update several fields at a time. + foreach ($update_fields as $field) { + content_field_instance_update($field, FALSE); + } + // Clear caches and rebuild menu. + content_clear_type_cache(TRUE); + menu_rebuild(); + + return $ret; +} diff --git a/link.module b/link.module index d095392..b1b3f72 100644 --- a/link.module +++ b/link.module @@ -37,7 +37,7 @@ define('LINK_TARGET_USER', 'user'); /** * Maximum URLs length. */ -define('LINK_URL_MAX_LENGTH', 255); +define('LINK_URL_MAX_LENGTH', 2048); /** * Implementation of hook_field_info(). @@ -181,7 +181,7 @@ function link_field_settings($op, $field) { case 'database columns': return array( - 'url' => array('type' => 'varchar', 'length' => LINK_URL_MAX_LENGTH, 'not null' => FALSE, 'sortable' => TRUE), + 'url' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE), 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'sortable' => TRUE), 'attributes' => array('type' => 'text', 'size' => 'medium', 'not null' => FALSE), );