Commit d16296bb authored by JonBob's avatar JonBob

#77539: Rename the node_type table to avoid conflict with a core table name.

parent c2cd38b2
......@@ -8,7 +8,7 @@ function content_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {node_type} (
db_query("CREATE TABLE {node_type_content} (
type_name varchar(32) NOT NULL default '',
label varchar(255) NOT NULL default '',
description mediumtext NOT NULL,
......@@ -38,7 +38,7 @@ function content_install() {
break;
case 'pgsql':
db_query("CREATE TABLE {node_type} (
db_query("CREATE TABLE {node_type_content} (
type_name varchar(32) NOT NULL default '',
label varchar(255) NOT NULL default '',
description text NOT NULL,
......@@ -222,3 +222,23 @@ function content_update_7() {
return $ret;
}
}
/**
* Rename the "node_type" table to avoid a conflict with a later core addition
*/
function content_update_8() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('RENAME TABLE {node_type} TO {node_type_content}');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {node_type} RENAME TO {node_type_content}');
break;
}
return $ret;
}
......@@ -698,7 +698,7 @@ function _content_type_info($reset = FALSE) {
$info['fields'][$field['field_name']] = $field;
}
$type_result = db_query('SELECT * FROM {node_type} nt ORDER BY nt.type_name ASC');
$type_result = db_query('SELECT * FROM {node_type_content} nt ORDER BY nt.type_name ASC');
while ($type = db_fetch_array($type_result)) {
$type['fields'] = array();
$field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description FROM {node_field_instance} nfi WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type['type_name']);
......
......@@ -47,7 +47,7 @@ function _content_admin_type_fields() {
$row[] = $field['type'];
$types = array();
$result = db_query("SELECT nt.label FROM {node_field_instance} nfi LEFT JOIN {node_type} nt ON nt.type_name = nfi.type_name WHERE nfi.field_name = '%s' ORDER BY nt.label ASC", $field['field_name']);
$result = db_query("SELECT nt.label FROM {node_field_instance} nfi LEFT JOIN {node_type_content} nt ON nt.type_name = nfi.type_name WHERE nfi.field_name = '%s' ORDER BY nt.label ASC", $field['field_name']);
while ($type = db_fetch_array($result)) {
$types[] = $type['label'];
}
......@@ -149,7 +149,7 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
$form_values['type_name'] = $new_name;
}
db_query("INSERT INTO {node_type} (type_name, label, description, help, title_label) VALUES ('%s', '%s', '%s', '%s', '%s')", $form_values['type_name'], $form_values['label'], $form_values['description'], $form_values['help'], $form_values['title_label']);
db_query("INSERT INTO {node_type_content} (type_name, label, description, help, title_label) VALUES ('%s', '%s', '%s', '%s', '%s')", $form_values['type_name'], $form_values['label'], $form_values['description'], $form_values['help'], $form_values['title_label']);
switch ($GLOBALS['db_type']) {
case 'mysql':
......@@ -171,7 +171,7 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
}
}
else {
db_query("UPDATE {node_type} SET label = '%s', description = '%s', help = '%s', title_label = '%s' WHERE type_name = '%s'", $form_values['label'], $form_values['description'], $form_values['help'], $form_values['title_label'], $form_values['type_name']);
db_query("UPDATE {node_type_content} SET label = '%s', description = '%s', help = '%s', title_label = '%s' WHERE type_name = '%s'", $form_values['label'], $form_values['description'], $form_values['help'], $form_values['title_label'], $form_values['type_name']);
}
if (isset($form_values['original_type_name'])) {
......@@ -211,7 +211,7 @@ function _content_admin_type_delete_submit($form_id, $form_values) {
node_delete($node->nid);
}
db_query("DELETE FROM {node_field_instance} WHERE type_name = '%s'", $form_values['type_name']);
db_query("DELETE FROM {node_type} WHERE type_name = '%s'", $form_values['type_name']);
db_query("DELETE FROM {node_type_content} WHERE type_name = '%s'", $form_values['type_name']);
db_query("DROP TABLE {node_". $form_values['type_name'] ."}");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment