Commit 552cf3b2 authored by JonBob's avatar JonBob

#60032: SQL error when deleting the last instance of a field.

parent c46b3c82
......@@ -134,7 +134,7 @@ function content_update_4() {
PRIMARY KEY (vid)
)");
break;
}
}
}
return $ret;
......@@ -157,7 +157,7 @@ function 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']];
......
......@@ -350,7 +350,7 @@ function content_field($op, &$node, $field, &$node_field, $teaser, $page) {
switch ($attributes['type']) {
case 'int':
case 'mediumint':
case 'tinyint':
case 'tinyint':
case 'bigint':
$column_placeholders[] = '%d';
$column_assignments[] = $attributes['column'] .' = %d';
......@@ -401,7 +401,7 @@ function content_field($op, &$node, $field, &$node_field, $teaser, $page) {
switch ($attributes['type']) {
case 'int':
case 'mediumint':
case 'tinyint':
case 'tinyint':
case 'bigint':
$column_placeholders[] = '%d';
$column_assignments[] = $attributes['column'] .' = %d';
......@@ -682,9 +682,9 @@ function content_database_info($field) {
$field_types = _content_field_types();
$module = $field_types[$field['type']]['module'];
$columns = module_invoke($module, 'field_settings', 'database columns', $field);
$db_info = array();
if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
$db_info['table'] = 'node_data_'. $field['field_name'];
}
......@@ -695,13 +695,13 @@ function content_database_info($field) {
if (is_array($columns) && count($columns)) {
$db_info['columns'] = $columns;
foreach ($columns as $column_name => $attributes) {
$db_info['columns'][$column_name]['column'] = $field['field_name'] .'_'. $column_name;
$db_info['columns'][$column_name]['column'] = $field['field_name'] .'_'. $column_name;
}
}
else {
$db_info['columns'] = array();
}
return $db_info;
}
......@@ -800,7 +800,7 @@ function content_views_tables() {
// We don't use $db_info['table'] for the key, since that may change during
// the lifetime of the field and we don't want to require users to redefine
// their views.
// their views.
$tables['node_data_'. $field['field_name']] = $table;
}
}
......
......@@ -168,7 +168,7 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
PRIMARY KEY (vid)
)");
break;
}
}
}
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']);
......@@ -679,7 +679,9 @@ function _content_admin_field_submit($form_id, $form_values) {
function content_alter_db_field($previous_field, $previous_columns, $new_field, $new_columns) {
// When adding and removing columns, we need to know what content type has an instance of the field.
if (count($previous_columns)) {
$previous_field['type_name'] = db_result(db_query("SELECT type_name FROM {node_field_instance} WHERE field_name = '%s'", $previous_field['field_name']));
if (!isset($previous_field['type_name'])) {
$previous_field['type_name'] = db_result(db_query("SELECT type_name FROM {node_field_instance} WHERE field_name = '%s'", $previous_field['field_name']));
}
$previous_db_info = content_database_info($previous_field);
}
if (count($new_columns)) {
......
......@@ -50,7 +50,7 @@ function nodereference_field_settings($op, $field) {
'#type' => 'checkboxes',
'#title' => t('Content types that can be referenced'),
'#multiple' => TRUE,
'#default_value' => $field['referenceable_types'],
'#default_value' => isset($field['referenceable_types']) ? $field['referenceable_types'] : array(),
'#options' => node_get_types(),
);
return $form;
......
......@@ -36,17 +36,17 @@ function number_field_settings($op, $field) {
$form['min'] = array(
'#type' => 'textfield',
'#title' => t('Minimum'),
'#default_value' => $field['min'] ? $field['min'] : '',
'#default_value' => isset($field['min']) ? $field['min'] : '',
);
$form['max'] = array(
'#type' => 'textfield',
'#title' => t('Maximum'),
'#default_value' => $field['max'] ? $field['max'] : '',
'#default_value' => isset($field['max']) ? $field['max'] : '',
);
$form['allowed_values'] = array(
'#type' => 'textarea',
'#title' => t('Allowed values'),
'#default_value' => $field['allowed_values'] ? $field['allowed_values'] : '',
'#default_value' => isset($field['allowed_values']) ? $field['allowed_values'] : '',
'#required' => FALSE,
'#rows' => 10,
'#description' => t('The possible values this field can contain. Any other values will result in an error. Enter one value per line.'),
......
......@@ -36,20 +36,20 @@ function text_field_settings($op, $field) {
$form['text_processing'] = array(
'#type' => 'radios',
'#title' => t('Text processing'),
'#default_value' => $field['text_processing'] ? $field['text_processing'] : 0,
'#default_value' => isset($field['text_processing']) ? $field['text_processing'] : 0,
'#options' => $options,
);
$form['max_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum length'),
'#default_value' => $field['max_length'] ? $field['max_length'] : '',
'#default_value' => isset($field['max_length']) ? $field['max_length'] : '',
'#required' => FALSE,
'#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
);
$form['allowed_values'] = array(
'#type' => 'textarea',
'#title' => t('Allowed values'),
'#default_value' => $field['allowed_values'] ? $field['allowed_values'] : '',
'#default_value' => isset($field['allowed_values']) ? $field['allowed_values'] : '',
'#required' => FALSE,
'#rows' => 10,
'#description' => t('The possible values this field can contain. Any other values will result in an error. Enter one value per line.'),
......
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