summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-14 20:52:46 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-14 20:52:46 +0200
commit1c2902ecbdaab493cb0a4a2fe3e46a2739c0d0fc (patch)
tree86e2f93ae38723e3eafca40e37b23b8a70af720d /Bugzilla
parent32b3964d567599b82019f9563fa732eced860223 (diff)
downloadbugzilla-1c2902ecbdaab493cb0a4a2fe3e46a2739c0d0fc.tar.gz
bugzilla-1c2902ecbdaab493cb0a4a2fe3e46a2739c0d0fc.tar.xz
Bug 578587: Make checksetup be way quieter when creating a new install
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DB.pm56
-rw-r--r--Bugzilla/DB/Mysql.pm5
-rw-r--r--Bugzilla/Group.pm7
-rw-r--r--Bugzilla/Install.pm19
-rw-r--r--Bugzilla/User/Setting.pm5
5 files changed, 69 insertions, 23 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index b1d8ca401..eeeff2280 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -37,7 +37,7 @@ use base qw(DBI::db);
use Bugzilla::Constants;
use Bugzilla::Install::Requirements;
-use Bugzilla::Install::Util qw(vers_cmp);
+use Bugzilla::Install::Util qw(vers_cmp install_string);
use Bugzilla::Install::Localconfig;
use Bugzilla::Util;
use Bugzilla::Error;
@@ -423,9 +423,13 @@ sub bz_setup_database {
$self->_bz_init_schema_storage();
my @desired_tables = $self->_bz_schema->get_table_list();
+ my $bugs_exists = $self->bz_table_info('bugs');
+ if (!$bugs_exists) {
+ print install_string('db_table_setup'), "\n";
+ }
foreach my $table_name (@desired_tables) {
- $self->bz_add_table($table_name);
+ $self->bz_add_table($table_name, { silently => !$bugs_exists });
}
}
@@ -435,17 +439,31 @@ sub bz_enum_initial_values {
}
sub bz_populate_enum_tables {
- my ($self) = @_;
+ my ($self) = @_;
+
+ my $any_severities = $self->selectrow_array(
+ 'SELECT 1 FROM bug_severity ' . $self->sql_limit(1));
+ print install_string('db_enum_setup'), "\n " if !$any_severities;
my $enum_values = $self->bz_enum_initial_values();
while (my ($table, $values) = each %$enum_values) {
$self->_bz_populate_enum_table($table, $values);
}
+
+ print "\n" if !$any_severities;
}
sub bz_setup_foreign_keys {
my ($self) = @_;
+ # profiles_activity was the first table to get foreign keys,
+ # so if it doesn't have them, then we're setting up FKs
+ # for the first time, and should be quieter about it.
+ my $activity_fk = $self->bz_fk_info('profiles_activity', 'userid');
+ if (!$activity_fk) {
+ print get_text('install_fk_setup'), "\n";
+ }
+
# We use _bz_schema because bz_add_table has removed all REFERENCES
# items from _bz_real_schema.
my @tables = $self->_bz_schema->get_table_list();
@@ -458,7 +476,7 @@ sub bz_setup_foreign_keys {
$add_fks{$column} = $def->{REFERENCES};
}
}
- $self->bz_add_fks($table, \%add_fks);
+ $self->bz_add_fks($table, \%add_fks, { silently => !$activity_fk });
}
}
@@ -516,7 +534,7 @@ sub bz_add_fk {
}
sub bz_add_fks {
- my ($self, $table, $column_fks) = @_;
+ my ($self, $table, $column_fks, $options) = @_;
my %add_these;
foreach my $column (keys %$column_fks) {
@@ -525,9 +543,13 @@ sub bz_add_fks {
my $fk = $column_fks->{$column};
$self->_check_references($table, $column, $fk);
$add_these{$column} = $fk;
- print get_text('install_fk_add',
- { table => $table, column => $column, fk => $fk })
- . "\n" if Bugzilla->usage_mode == USAGE_MODE_CMDLINE;
+ if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE
+ and !$options->{silently})
+ {
+ print get_text('install_fk_add',
+ { table => $table, column => $column, fk => $fk }),
+ "\n";
+ }
}
return if !scalar(keys %add_these);
@@ -650,12 +672,12 @@ sub bz_add_index_raw {
}
sub bz_add_table {
- my ($self, $name) = @_;
+ my ($self, $name, $options) = @_;
my $table_exists = $self->bz_table_info($name);
if (!$table_exists) {
- $self->_bz_add_table_raw($name);
+ $self->_bz_add_table_raw($name, $options);
my $table_def = dclone($self->_bz_schema->get_table_abstract($name));
my %fields = @{$table_def->{FIELDS}};
@@ -686,10 +708,13 @@ sub bz_add_table {
# Returns: nothing
#
sub _bz_add_table_raw {
- my ($self, $name) = @_;
+ my ($self, $name, $options) = @_;
my @statements = $self->_bz_schema->get_table_ddl($name);
- print "Adding new table $name ...\n"
- if Bugzilla->usage_mode == USAGE_MODE_CMDLINE;
+ if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE
+ and !$options->{silently})
+ {
+ print install_string('db_table_new', { table => $name }), "\n";
+ }
$self->do($_) foreach (@statements);
}
@@ -1181,7 +1206,7 @@ sub _bz_init_schema_storage {
$self->_bz_add_table_raw('bz_schema');
}
- print "Initializing the new Schema storage...\n";
+ print install_string('db_schema_init'), "\n";
my $sth = $self->prepare("INSERT INTO bz_schema "
." (schema_data, version) VALUES (?,?)");
$sth->bind_param(1, $store_me, $self->BLOB_TYPE);
@@ -1284,14 +1309,13 @@ sub _bz_populate_enum_table {
# If the table is empty...
if (!$table_size) {
+ print " $table";
my $insert = $self->prepare(
"INSERT INTO $sql_table (value,sortkey) VALUES (?,?)");
- print "Inserting values into the '$table' table:\n";
my $sortorder = 0;
my $maxlen = max(map(length($_), @$valuelist)) + 2;
foreach my $value (@$valuelist) {
$sortorder += 100;
- printf "%-${maxlen}s sortkey: $sortorder\n", "'$value'";
$insert->execute($value, $sortorder);
}
}
diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm
index 7f3eb2ef8..66a261c75 100644
--- a/Bugzilla/DB/Mysql.pm
+++ b/Bugzilla/DB/Mysql.pm
@@ -1065,11 +1065,12 @@ this code does.
sub _bz_build_schema_from_disk {
my ($self) = @_;
- print "Building Schema object from database...\n";
-
my $schema = $self->_bz_schema->get_empty_schema();
my @tables = $self->bz_table_list_real();
+ if (@tables) {
+ print "Building Schema object from database...\n";
+ }
foreach my $table (@tables) {
$schema->add_table($table);
my @columns = $self->bz_table_columns_real($table);
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm
index a8786034b..eef0a70cd 100644
--- a/Bugzilla/Group.pm
+++ b/Bugzilla/Group.pm
@@ -389,8 +389,11 @@ sub create {
my ($params) = @_;
my $dbh = Bugzilla->dbh;
- print get_text('install_group_create', { name => $params->{name} }) . "\n"
- if Bugzilla->usage_mode == USAGE_MODE_CMDLINE;
+ my $silently = delete $params->{silently};
+ if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE and !$silently) {
+ print get_text('install_group_create', { name => $params->{name} }),
+ "\n";
+ }
$dbh->bz_start_transaction();
diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm
index 9536f4645..ed604d029 100644
--- a/Bugzilla/Install.pm
+++ b/Bugzilla/Install.pm
@@ -174,12 +174,21 @@ use constant DEFAULT_COMPONENT => {
};
sub update_settings {
+ my $dbh = Bugzilla->dbh;
+ # If we're setting up settings for the first time, we want to be quieter.
+ my $any_settings = $dbh->selectrow_array(
+ 'SELECT 1 FROM setting ' . $dbh->sql_limit(1));
+ if (!$any_settings) {
+ print get_text('install_setting_setup'), "\n";
+ }
+
my %settings = %{SETTINGS()};
foreach my $setting (keys %settings) {
add_setting($setting,
$settings{$setting}->{options},
$settings{$setting}->{default},
- $settings{$setting}->{subclass});
+ $settings{$setting}->{subclass}, undef,
+ !$any_settings);
}
}
@@ -188,11 +197,19 @@ sub update_system_groups {
$dbh->bz_start_transaction();
+ # If there is no editbugs group, this is the first time we're
+ # adding groups.
+ my $editbugs_exists = new Bugzilla::Group({ name => 'editbugs' });
+ if (!$editbugs_exists) {
+ print get_text('install_groups_setup'), "\n";
+ }
+
# Create most of the system groups
foreach my $definition (SYSTEM_GROUPS) {
my $exists = new Bugzilla::Group({ name => $definition->{name} });
if (!$exists) {
$definition->{isbuggroup} = 0;
+ $definition->{silently} = !$editbugs_exists;
my $inherited_by = delete $definition->{inherited_by};
my $created = Bugzilla::Group->create($definition);
# Each group in inherited_by is automatically a member of this
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm
index 7a6c72fd3..78e64c96b 100644
--- a/Bugzilla/User/Setting.pm
+++ b/Bugzilla/User/Setting.pm
@@ -125,7 +125,8 @@ sub new {
###############################
sub add_setting {
- my ($name, $values, $default_value, $subclass, $force_check) = @_;
+ my ($name, $values, $default_value, $subclass, $force_check,
+ $silently) = @_;
my $dbh = Bugzilla->dbh;
my $exists = _setting_exists($name);
@@ -146,7 +147,7 @@ sub add_setting {
undef, $name);
}
}
- else {
+ elsif (!$silently) {
print get_text('install_setting_new', { name => $name }) . "\n";
}
$dbh->do(q{INSERT INTO setting (name, default_value, is_enabled, subclass)