#173566 by bjaspan: remove db_update_field(), because it can easily be used for evil (and mostly nothing else). We should not let contributed modules to easily break their database.
parent
a6f970e9d2
commit
92d9533353
|
@ -452,22 +452,6 @@ function db_change_field(&$ret, $table, $field, $field_new, $spec) {
|
|||
_db_create_field_sql($field_new, _db_process_field($spec)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a field definition to match its schema. If the field is
|
||||
* involved in any keys or indexes, recreate them.
|
||||
*
|
||||
* @param $ret
|
||||
* Array to which query results will be added.
|
||||
* @param $table
|
||||
* Name of the table.
|
||||
* @param $field
|
||||
* Name of the field to update.
|
||||
*/
|
||||
function db_update_field(&$ret, $table, $field) {
|
||||
$spec = drupal_get_schema($table);
|
||||
db_change_field($ret, $table, $field, $field, $spec['fields'][$field]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last insert id.
|
||||
*
|
||||
|
|
|
@ -863,42 +863,6 @@ function db_change_field(&$ret, $table, $field, $field_new, $spec) {
|
|||
db_drop_field($ret, $table, $field .'_old');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a field definition to match its schema. If the field is
|
||||
* involved in any keys or indexes, recreate them if necessary.
|
||||
*
|
||||
* @param $ret
|
||||
* Array to which query results will be added.
|
||||
* @param $table
|
||||
* Name of the table.
|
||||
* @param $field
|
||||
* Name of the field to update.
|
||||
*/
|
||||
function db_update_field(&$ret, $table, $field) {
|
||||
$spec = drupal_get_schema($table);
|
||||
|
||||
db_change_field($ret, $table, $field, $field, $spec['fields'][$field]);
|
||||
if (isset($spec['primary key'])) {
|
||||
if (array_search($field, db_field_names($spec['primary key'])) !== FALSE) {
|
||||
db_add_primary_key($ret, $table, $spec['primary key']);
|
||||
}
|
||||
}
|
||||
if (isset($spec['unique keys'])) {
|
||||
foreach ($spec['unique keys'] as $name => $fields) {
|
||||
if (array_search($field, db_field_names($fields)) !== FALSE) {
|
||||
db_add_unique_key($ret, $table, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($spec['indexes'])) {
|
||||
foreach ($spec['indexes'] as $name => $fields) {
|
||||
if (array_search($field, db_field_names($fields)) !== FALSE) {
|
||||
db_add_index($ret, $table, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "ingroup schemaapi".
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue