]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 419979: Bugzilla::DB::bz_add_field_table directly modifies the FIELD_TABLE_SCHEMA...
authormkanat%bugzilla.org <>
Tue, 25 Mar 2008 03:50:40 +0000 (03:50 +0000)
committermkanat%bugzilla.org <>
Tue, 25 Mar 2008 03:50:40 +0000 (03:50 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat

Bugzilla/DB.pm

index 7a19f8fd42a98009a3f9ed8e8f79a24f8ae3bbd7..ff3df50672f0e45ee71e8a284d2d0cd5cd21c450 100644 (file)
@@ -597,18 +597,21 @@ sub _bz_add_table_raw {
 
 sub bz_add_field_table {
     my ($self, $name) = @_;
-    my $table_schema = $self->_bz_schema->FIELD_TABLE_SCHEMA;
     # 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 constant.
+    my %table_schema = %{ $self->_bz_schema->FIELD_TABLE_SCHEMA };
+    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);
 }