From 634f31d6c64894bcf2f0788525e9a9286e9de314 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Wed, 8 Apr 2015 18:41:26 +0100 Subject: Bug 1090493: Allow ComponentWatching extension to work on either bmo/4.2 or upstream 5.0+ --- extensions/ComponentWatching/Extension.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'extensions/ComponentWatching') diff --git a/extensions/ComponentWatching/Extension.pm b/extensions/ComponentWatching/Extension.pm index 0af1ae6cf..1f507493f 100644 --- a/extensions/ComponentWatching/Extension.pm +++ b/extensions/ComponentWatching/Extension.pm @@ -29,6 +29,18 @@ use constant REL_COMPONENT_WATCHER => 15; sub db_schema_abstract_schema { my ($self, $args) = @_; + my $dbh = Bugzilla->dbh; + + # Bugzilla 5.0+, the components.id type + # is INT3, while earlier versions used INT2 + my $component_id_type = 'INT2'; + my $len = scalar @{ $args->{schema}->{components}->{FIELDS} }; + for (my $i = 0; $i < $len - 1; $i+=2) { + next if $args->{schema}->{components}->{FIELDS}->[$i] ne 'id'; + $component_id_type = 'INT3' + if $args->{schema}->{components}->{FIELDS}->[$i+1]->{TYPE} eq 'MEDIUMSERIAL'; + last; + } $args->{'schema'}->{'component_watch'} = { FIELDS => [ id => { @@ -46,7 +58,7 @@ sub db_schema_abstract_schema { } }, component_id => { - TYPE => 'INT2', + TYPE => $component_id_type, NOTNULL => 0, REFERENCES => { TABLE => 'components', -- cgit v1.2.3-24-g4f1b