function content_update_7 in Content Construction Kit (CCK) 5
Rename the "content-" prefix to "content_" to aid in form theming.
File
- ./
content.install, line 243
Code
function content_update_7() {
$ret = array();
// Figure out what table to update. If node_type exists and node_type_content does not, this update is
// being done by an early version of core that did not rename the node_type table, so use the original name, node_type.
// If both table names exist, core has renamed the table, so use the renamed table name, node_type_content.
if (!db_table_exists('node_type_content')) {
$table_name = 'node_type';
}
else {
$table_name = 'node_type_content';
}
$type_result = db_query("SELECT type_name FROM {" . $table_name . "} WHERE type_name LIKE 'content-%%'");
if (db_num_rows($type_result)) {
// Multi-part update
if (!isset($_SESSION['content_update_7'])) {
$_SESSION['content_update_7'] = 0;
$_SESSION['content_update_7_max'] = db_num_rows($type_result);
}
$type = db_fetch_object($type_result);
$old_type_name = $type->type_name;
$new_type_name = str_replace('content-', 'content_', $old_type_name);
$ret[] = update_sql("UPDATE {node} SET type = '" . $new_type_name . "' WHERE type = '" . $old_type_name . "'");
$ret[] = update_sql("UPDATE {" . $table_name . "} SET type_name = '" . $new_type_name . "' WHERE type_name = '" . $old_type_name . "'");
$ret[] = update_sql("UPDATE {node_field_instance} SET type_name = '" . $new_type_name . "' WHERE type_name = '" . $old_type_name . "'");
$ret[] = update_sql("UPDATE {vocabulary_node_types} SET type = '" . $new_type_name . "' WHERE type = '" . $old_type_name . "'");
$variable_result = db_query("SELECT name, value FROM {variable} WHERE name LIKE '%%%s%%' OR value LIKE '%%%s%%'", $old_type_name, $old_type_name);
while ($variable = db_fetch_object($variable_result)) {
$new_name = str_replace($old_type_name, $new_type_name, $variable->name);
$new_value = str_replace($old_type_name, $new_type_name, $variable->value);
db_query("UPDATE {variable} SET name = '%s', value = '%s' WHERE name = '%s'", $new_name, $new_value, $variable->name);
}
$ret[] = update_sql('DELETE FROM {cache}');
$_SESSION['content_update_7']++;
$ret['#finished'] = $_SESSION['content_update_7'] / $_SESSION['content_update_7_max'];
return $ret;
}
}