From 460eb160b7d524b38fe7ea340922521c333282d7 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 8 Sep 2006 06:41:32 +0000 Subject: Bug 350217: Extensions need to be able to update Bugzilla's DB schema Patch By Max Kanat-Alexander r=ghendricks, a=myk --- Bugzilla/DB/Schema.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Bugzilla/DB') 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 -- cgit v1.2.3-24-g4f1b