]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 569302: Make sure that Install::DB functions always print out a message
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Tue, 1 Jun 2010 05:30:16 +0000 (22:30 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Tue, 1 Jun 2010 05:30:16 +0000 (22:30 -0700)
if they are conditionally doing something to the database.
r=mkanat, a=mkanat (module owner)

Bugzilla/Install/DB.pm

index e7d9c675c45b9e0d5d69ef04dbe8d19a34a35a81..051f2dc2528485281f52bea1d8ea3182aea44b9e 100644 (file)
@@ -1032,6 +1032,7 @@ sub _copy_from_comments_to_longdescs {
     # 2000-11-27 For Bugzilla 2.5 and later. Copy data from 'comments' to
     # 'longdescs' - the new name of the comments table.
     if ($dbh->bz_table_info('comments')) {
+        print "Copying data from 'comments' to 'longdescs'...\n";
         my $quoted_when = $dbh->quote_identifier('when');
         $dbh->do("INSERT INTO longdescs (bug_when, bug_id, who, thetext)
                   SELECT $quoted_when, bug_id, who, comment
@@ -1239,6 +1240,7 @@ sub _use_ip_instead_of_hostname_in_logincookies {
     #
     # Use the ip, not the hostname, in the logincookies table
     if ($dbh->bz_column_info("logincookies", "hostname")) {
+        print "Clearing the logincookies table...\n";
         # We've changed what we match against, so all entries are now invalid
         $dbh->do("DELETE FROM logincookies");
 
@@ -1978,9 +1980,11 @@ sub _copy_old_charts_into_database {
         my $all_name = "-All-";
         my $open_name = "All Open";
 
+        $dbh->bz_start_transaction();
         my $products = $dbh->selectall_arrayref("SELECT name FROM products");
 
         foreach my $product ((map { $_->[0] } @$products), "-All-") {
+            print "$product:\n";
             # First, create the series
             my %queries;
             my %seriesids;
@@ -2029,8 +2033,9 @@ sub _copy_old_charts_into_database {
             my %data;
             my $last_date = "";
 
-            while (<$in>) {
-                if (/^(\d+\|.*)/) {
+            my @lines = <$in>;
+            while (my $line = shift @lines) {
+                if ($line =~ /^(\d+\|.*)/) {
                     my @numbers = split(/\||\r/, $1);
 
                     # Only take the first line for each date; it was possible to
@@ -2053,6 +2058,9 @@ sub _copy_old_charts_into_database {
 
             $in->close;
 
+            my $total_items = (scalar(@fields) + 1) 
+                              * scalar(keys %{ $data{'NEW'} });
+            my $count = 0;
             foreach my $field (@fields, $open_name) {
                 # Insert values into series_data: series_id, date, value
                 my %fielddata = %{$data{$field}};
@@ -2064,6 +2072,8 @@ sub _copy_old_charts_into_database {
                     # We prepared this above
                     $seriesdatasth->execute($seriesids{$field},
                                             $date, $fielddata{$date} || 0);
+                    indicate_progress({ total => $total_items, 
+                                        current => ++$count, every => 100 });
                 }
             }
 
@@ -2090,6 +2100,8 @@ sub _copy_old_charts_into_database {
                 }
             }
         }
+
+        $dbh->bz_commit_transaction();
     }
 }
 
@@ -2158,7 +2170,7 @@ sub _convert_attachments_filename_from_mediumtext {
     # and attachment.cgi now takes them out, but old ones need converting.
     my $ref = $dbh->bz_column_info("attachments", "filename");
     if ($ref->{TYPE} ne 'varchar(100)') {
-        print "Removing paths from filenames in attachments table...\n";
+        print "Removing paths from filenames in attachments table...";
 
         my $sth = $dbh->prepare("SELECT attach_id, filename FROM attachments " .
             "WHERE " . $dbh->sql_position(q{'/'}, 'filename') . " > 0 OR " .
@@ -2174,8 +2186,6 @@ sub _convert_attachments_filename_from_mediumtext {
 
         print "Done.\n";
 
-        print "Resizing attachments.filename from mediumtext to",
-              " varchar(100).\n";
         $dbh->bz_alter_column("attachments", "filename",
                               {TYPE => 'varchar(100)', NOTNULL => 1});
     }
@@ -3150,16 +3160,17 @@ sub _populate_bugs_fulltext {
         $bug_ids ||= $dbh->selectcol_arrayref('SELECT bug_id FROM bugs');
         # If there are no bugs in the bugs table, there's nothing to populate.
         return if !@$bug_ids;
+        my $num_bugs = scalar @$bug_ids;
 
         my $where = "";
         if ($fulltext) {
-            print "Updating bugs_fulltext...\n";
+            print "Updating bugs_fulltext for $num_bugs bugs...\n";
             $where = "WHERE " . $dbh->sql_in('bugs.bug_id', $bug_ids);
             $dbh->do("DELETE FROM bugs_fulltext WHERE " 
                      . $dbh->sql_in('bug_id', $bug_ids));
         }
         else {
-            print "Populating bugs_fulltext...";
+            print "Populating bugs_fulltext with $num_bugs entries...";
             print " (this can take a long time.)\n";
         }
         my $newline = $dbh->quote("\n");
@@ -3244,9 +3255,9 @@ sub _fix_invalid_custom_field_names {
         next if $field->name =~ /^[a-zA-Z0-9_]+$/;
         # The field name is illegal and can break the DB. Kill the field!
         $field->set_obsolete(1);
-        eval { $field->remove_from_db(); };
         print "Removing custom field '" . $field->name . "' (illegal name)... ";
-        print $@ ? "failed\n$@\n" : "succeeded\n";
+        eval { $field->remove_from_db(); };
+        print $@ ? "failed:\n$@\n" : "succeeded\n";
     }
 }