From 97ac79dcfee3a1b19a20816a31b0a79194ae75fe Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 23 Oct 2014 17:40:55 +0000 Subject: Bug 1082113: The ComponentWatching extension should create a default watch user with a new database installation --- extensions/ComponentWatching/Extension.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'extensions/ComponentWatching') diff --git a/extensions/ComponentWatching/Extension.pm b/extensions/ComponentWatching/Extension.pm index 627fb12fd..38b1abb3c 100644 --- a/extensions/ComponentWatching/Extension.pm +++ b/extensions/ComponentWatching/Extension.pm @@ -164,8 +164,23 @@ sub object_before_create { my $params = $args->{params}; return unless $class->isa('Bugzilla::Component'); - my $input = Bugzilla->input_params; - $params->{watch_user} = $input->{watch_user}; + # We need to create a watch user for the default product/component + # if we are creating the database for the first time. + my $dbh = Bugzilla->dbh; + if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE + && !$dbh->selectrow_array('SELECT 1 FROM components')) + { + my $watch_user = Bugzilla::User->create({ + login_name => 'testcomponent@testproduct.bugs', + cryptpassword => '*', + disable_mail => 1 + }); + $params->{watch_user} = $watch_user->login; + } + else { + my $input = Bugzilla->input_params; + $params->{watch_user} = $input->{watch_user}; + } } sub object_end_of_update { -- cgit v1.2.3-24-g4f1b