diff options
author | mkanat%bugzilla.org <> | 2008-10-03 06:37:16 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-10-03 06:37:16 +0000 |
commit | b03fc56082401474044c7f92f8786164ca0508a4 (patch) | |
tree | 060d369e1ac921ea158149379a3a2cdadb214f72 /editvalues.cgi | |
parent | Bug 455641: Implement Bugzilla::Field::Choice->update and have editvalues.cgi... (diff) | |
download | bugzilla-b03fc56082401474044c7f92f8786164ca0508a4.tar.gz bugzilla-b03fc56082401474044c7f92f8786164ca0508a4.tar.bz2 bugzilla-b03fc56082401474044c7f92f8786164ca0508a4.zip |
Bug 456919: Implement Bugzilla::Field::Choice->remove_from_db and have editvalues.cgi use it
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat
Diffstat (limited to 'editvalues.cgi')
-rwxr-xr-x | editvalues.cgi | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/editvalues.cgi b/editvalues.cgi index f6a602b55..2992a5f3d 100755 --- a/editvalues.cgi +++ b/editvalues.cgi @@ -265,58 +265,10 @@ if ($action eq 'del') { # if ($action eq 'delete') { check_token_data($token, 'delete_field_value'); - ValueMustExist($field, $value); - - $vars->{'value'} = $value; - $vars->{'param_name'} = $defaults{$field}; - - if (defined $defaults{$field} - && ($value eq Bugzilla->params->{$defaults{$field}})) - { - ThrowUserError('fieldvalue_is_default', $vars); - } - # If the value cannot be deleted, throw an error. - if (lsearch($static{$field}, $value) >= 0) { - ThrowUserError('fieldvalue_not_deletable', $vars); - } - - trick_taint($value); - - $dbh->bz_start_transaction(); - - # Check if there are any bugs that still have this value. - my $bug_count; - if ($field_obj->type != FIELD_TYPE_MULTI_SELECT) { - $bug_count = - $dbh->selectrow_array("SELECT COUNT(*) FROM bugs WHERE $field = ?", - undef, $value); - } - else { - $bug_count = - $dbh->selectrow_array("SELECT COUNT(*) FROM bug_$field WHERE value = ?", - undef, $value); - } - - - if ($bug_count) { - # You tried to delete a field that bugs are still using. - # You can't just delete the bugs. That's ridiculous. - ThrowUserError("fieldvalue_still_has_bugs", - { field => $field, value => $value, - count => $bug_count }); - } - - if ($field eq 'bug_status') { - my $status_id = $dbh->selectrow_arrayref('SELECT id FROM bug_status - WHERE value = ?', undef, $value); - $dbh->do('DELETE FROM status_workflow - WHERE old_status = ? OR new_status = ?', - undef, ($status_id, $status_id)); - } - - $dbh->do("DELETE FROM $field WHERE value = ?", undef, $value); + my $value_obj = Bugzilla::Field::Choice->type($field)->check($value); + $vars->{'value'} = $value_obj->name; + $value_obj->remove_from_db(); - $dbh->bz_commit_transaction(); delete_token($token); $vars->{'message'} = 'field_value_deleted'; |