function content_update_5 in Content Construction Kit (CCK) 5
Move data from per-field storage to per-content-type storage where possible.
File
- ./
content.install, line 196
Code
function content_update_5() {
$ret = array();
include_once './' . drupal_get_path('module', 'content') . '/content.module';
include_once './' . drupal_get_path('module', 'content') . '/content_admin.inc';
content_clear_type_cache();
$result = db_query('SELECT nf.field_name FROM {node_field} nf LEFT JOIN {node_field_instance} nfi ON nfi.field_name = nf.field_name WHERE nf.multiple = 0 AND nf.db_storage = 0 GROUP BY nfi.field_name HAVING COUNT(*) = 1');
if (db_num_rows($result)) {
// Multi-part update
if (!isset($_SESSION['content_update_5'])) {
$_SESSION['content_update_5'] = 0;
$_SESSION['content_update_5_max'] = db_num_rows($result);
}
$field = db_fetch_array($result);
$fields = content_fields();
$field = $fields[$field['field_name']];
$field_types = _content_field_types();
$field_type = $field_types[$field['type']];
$columns = module_invoke($field_type['module'], 'field_settings', 'database columns', $field);
$ret[] = update_sql("UPDATE {node_field} SET db_storage = " . CONTENT_DB_STORAGE_PER_CONTENT_TYPE . " WHERE field_name = '" . $field['field_name'] . "'");
if (is_array($columns) && count($columns)) {
$new_field = $field;
$new_field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
content_alter_db_field($field, $columns, $new_field, $columns);
}
$_SESSION['content_update_5']++;
$ret['#finished'] = $_SESSION['content_update_5'] / $_SESSION['content_update_5_max'];
return $ret;
}
}