summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-03-25 04:49:32 +0100
committermkanat%bugzilla.org <>2008-03-25 04:49:32 +0100
commit91b55fc9699d8997d5b468117116e52c5bfb6a45 (patch)
treef146a2e5e1322642a24f4af3f20ff4d243b2095c /Bugzilla
parent2429c5daba37968dacb9b84e6eb671b057765fda (diff)
downloadbugzilla-91b55fc9699d8997d5b468117116e52c5bfb6a45.tar.gz
bugzilla-91b55fc9699d8997d5b468117116e52c5bfb6a45.tar.xz
Bug 419979: Bugzilla::DB::bz_add_field_table directly modifies the FIELD_TABLE_SCHEMA constant
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DB.pm21
1 files changed, 13 insertions, 8 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 6763da06b..d74284b27 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -660,18 +660,23 @@ sub _bz_add_table_raw {
}
sub _bz_add_field_table {
- my ($self, $name, $table_schema) = @_;
+ my ($self, $name, $schema_ref) = @_;
# We do nothing if the table already exists.
return if $self->bz_table_info($name);
- my $indexes = $table_schema->{INDEXES};
- # $indexes is an arrayref, not a hash. In order to fix the keys,
- # we have to fix every other item.
- for (my $i = 0; $i < scalar @$indexes; $i++) {
- next if ($i % 2 && $i != 0); # We skip 1, 3, 5, 7, etc.
- $indexes->[$i] = $name . "_" . $indexes->[$i];
+
+ # Copy this so that we're not modifying the passed reference.
+ # (This avoids modifying a constant in Bugzilla::DB::Schema.)
+ my %table_schema = %$schema_ref;
+ my %indexes = @{ $table_schema{INDEXES} };
+ my %fixed_indexes;
+ foreach my $key (keys %indexes) {
+ $fixed_indexes{$name . "_" . $key} = $indexes{$key};
}
+ # INDEXES is supposed to be an arrayref, so we have to convert back.
+ my @indexes_array = %fixed_indexes;
+ $table_schema{INDEXES} = \@indexes_array;
# We add this to the abstract schema so that bz_add_table can find it.
- $self->_bz_schema->add_table($name, $table_schema);
+ $self->_bz_schema->add_table($name, \%table_schema);
$self->bz_add_table($name);
}