summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2012-10-19 01:24:10 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-10-19 01:24:10 +0200
commitc8f6709789dd430777f99d868439d49f6d7d51d3 (patch)
tree0c3b027553c15ed94f05baff20431b13926b6d47
parent71ce45b150b938a2c18a7809f5afe23e2c2e7c49 (diff)
downloadbugzilla-c8f6709789dd430777f99d868439d49f6d7d51d3.tar.gz
bugzilla-c8f6709789dd430777f99d868439d49f6d7d51d3.tar.xz
Bug 531243: Bugzilla crashes on show_bug if it's hit while a custom field is being added
r=justdave a=LpSolit
-rw-r--r--Bugzilla/Field.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index dbee5df3d..81677c7ea 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -1016,7 +1016,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);
@@ -1045,6 +1049,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;