From fc443eda7c58d236302c9b07017ba6cb059a6120 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Fri, 19 Oct 2012 01:21:44 +0200 Subject: Bug 531243: Bugzilla crashes on show_bug if it's hit while a custom field is being added r=justdave a=LpSolit --- Bugzilla/Field.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Bugzilla/Field.pm') diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 64d5da574..87b307cb7 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -1035,7 +1035,11 @@ sub create { # the parameter isn't sent to create(). $params->{sortkey} = undef if !exists $params->{sortkey}; $params->{type} ||= 0; - + # We mark the custom field as obsolete till it has been fully created, + # to avoid race conditions when viewing bugs at the same time. + my $is_obsolete = $params->{obsolete}; + $params->{obsolete} = 1 if $params->{custom}; + $dbh->bz_start_transaction(); $class->check_required_create_fields(@_); my $field_values = $class->run_create_validators($params); @@ -1064,6 +1068,10 @@ sub create { # Insert a default value of "---" into the legal values table. $dbh->do("INSERT INTO $name (value) VALUES ('---')"); } + + # Restore the original obsolete state of the custom field. + $dbh->do('UPDATE fielddefs SET obsolete = 0 WHERE id = ?', undef, $field->id) + unless $is_obsolete; } return $field; -- cgit v1.2.3-24-g4f1b