summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-09-08 08:41:32 +0200
committermkanat%bugzilla.org <>2006-09-08 08:41:32 +0200
commit460eb160b7d524b38fe7ea340922521c333282d7 (patch)
tree47c5486a0876cdab4871b605c15787719153b3c6 /Bugzilla/DB
parent666dd28a656b6893c96e837517e5ee65e19e1447 (diff)
downloadbugzilla-460eb160b7d524b38fe7ea340922521c333282d7.tar.gz
bugzilla-460eb160b7d524b38fe7ea340922521c333282d7.tar.xz
Bug 350217: Extensions need to be able to update Bugzilla's DB schema
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=ghendricks, a=myk
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r--Bugzilla/DB/Schema.pm11
1 files changed, 11 insertions, 0 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index ea25a125a..4c270e68c 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -35,9 +35,11 @@ package Bugzilla::DB::Schema;
use strict;
use Bugzilla::Error;
+use Bugzilla::Hook;
use Bugzilla::Util;
use Bugzilla::Constants;
+use Hash::Util qw(lock_value unlock_hash lock_keys unlock_keys);
use Safe;
# Historical, needed for SCHEMA_VERSION = '1.00'
use Storable qw(dclone freeze thaw);
@@ -1168,6 +1170,15 @@ sub _initialize {
$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);
+
$self->{schema} = dclone($abstract_schema);
# While ABSTRACT_SCHEMA cannot be modified,
# $self->{abstract_schema} can be. So, we dclone it to prevent