summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-05-26 03:18:03 +0200
committermkanat%bugzilla.org <>2007-05-26 03:18:03 +0200
commit23c0a8a13502201d01354e9262fa30c45d56ddd7 (patch)
tree61827d3a3a711adf5ce1f57a5c559635bf8c4c50
parent4d5504d623fa875816c9c10826229dcf7ccd2b26 (diff)
downloadbugzilla-23c0a8a13502201d01354e9262fa30c45d56ddd7.tar.gz
bugzilla-23c0a8a13502201d01354e9262fa30c45d56ddd7.tar.xz
Bug 381640: abstract_schema hook is broken--it prevents modification of the extension's own tables
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
-rw-r--r--Bugzilla/DB/Schema.pm32
1 files changed, 18 insertions, 14 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index e9205ba0b..35e786c51 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -1331,22 +1331,26 @@ sub _initialize {
my $self = shift;
my $abstract_schema = shift;
- $abstract_schema ||= ABSTRACT_SCHEMA;
-
- # Let extensions add tables, but make sure they can't modify existing
- # tables. If we don't lock/unlock keys, lock_value complains.
- lock_keys(%$abstract_schema);
- lock_value(%$abstract_schema, $_) foreach (keys %$abstract_schema);
- unlock_keys(%$abstract_schema);
- Bugzilla::Hook::process('db_schema-abstract_schema',
- { schema => $abstract_schema });
- unlock_hash(%$abstract_schema);
+ if (!$abstract_schema) {
+ # While ABSTRACT_SCHEMA cannot be modified, $abstract_schema can be.
+ # So, we dclone it to prevent anything from mucking with the constant.
+ $abstract_schema = dclone(ABSTRACT_SCHEMA);
+
+ # Let extensions add tables, but make sure they can't modify existing
+ # tables. If we don't lock/unlock keys, lock_value complains.
+ lock_keys(%$abstract_schema);
+ foreach my $table (keys %{ABSTRACT_SCHEMA()}) {
+ lock_value(%$abstract_schema, $table)
+ if exists $abstract_schema->{$table};
+ }
+ unlock_keys(%$abstract_schema);
+ Bugzilla::Hook::process('db_schema-abstract_schema',
+ { schema => $abstract_schema });
+ unlock_hash(%$abstract_schema);
+ }
$self->{schema} = dclone($abstract_schema);
- # While ABSTRACT_SCHEMA cannot be modified,
- # $self->{abstract_schema} can be. So, we dclone it to prevent
- # anything from mucking with the constant.
- $self->{abstract_schema} = dclone($abstract_schema);
+ $self->{abstract_schema} = $abstract_schema;
return $self;