You are here

function text_update_6000 in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 modules/text/text.install \text_update_6000()
  2. 6 modules/text/text.install \text_update_6000()

Rename widgets to match hook_elements values.

The change in field_types will keep content_update_6000() from correctly updating the module names in the field and instance tables, so do it here.

1 call to text_update_6000()
text_update_6002 in modules/text/text.install
Update 6000 and 6001 were possibly broken if they were executed while the modules were still disabled, so we re-run them. Having them run a second time on sites that got updated correctly has no side-effect (see http://drupal.org/node/310873).

File

modules/text/text.install, line 51
Implementation of hook_install().

Code

function text_update_6000() {
  if ($abort = content_check_update('text')) {
    return $abort;
  }
  $ret = array();
  drupal_load('module', 'content');
  $result = db_query("SELECT * FROM {" . content_instance_tablename() . "} WHERE widget_type = 'text'");
  while ($field_instance = db_fetch_array($result)) {
    $widget_settings = unserialize($field_instance['widget_settings']);
    $new_widget_type = $widget_settings['rows'] > 1 ? 'text_textarea' : 'text_textfield';
    $ret[] = update_sql("UPDATE {" . content_instance_tablename() . "} SET widget_module = 'text', widget_type = '" . $new_widget_type . "' WHERE field_name = '{$field_instance['field_name']}' AND type_name = '{$field_instance['type_name']}'");
  }
  content_associate_fields('text');
  return $ret;
}