From: Frédéric Buclin Date: Thu, 18 Oct 2012 23:23:01 +0000 (+0200) Subject: Bug 531243: Bugzilla crashes on show_bug if it's hit while a custom field is being... X-Git-Tag: bugzilla-4.4rc1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3e71225e3530d05736bc1a7b9c92ac534f1b1aa;p=thirdparty%2Fbugzilla.git Bug 531243: Bugzilla crashes on show_bug if it's hit while a custom field is being added r=justdave a=LpSolit --- diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 228bea7379..c4d687afb8 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -1034,7 +1034,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); @@ -1063,6 +1067,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;