diff options
author | gerv%gerv.net <> | 2001-01-18 00:52:20 +0100 |
---|---|---|
committer | gerv%gerv.net <> | 2001-01-18 00:52:20 +0100 |
commit | 2093c1cbb3a2837a0d7136d973b0ee594b00d46f (patch) | |
tree | fa737bd246eef5b0c5a006560fa4c4ab3feb513f | |
parent | 9e3652ab9c1add7c21f818f6d6d9cf26b4b78ba3 (diff) | |
download | bugzilla-2093c1cbb3a2837a0d7136d973b0ee594b00d46f.tar.gz bugzilla-2093c1cbb3a2837a0d7136d973b0ee594b00d46f.tar.xz |
Code to upgrade data file formats from old version, and intermediate broken version. Bug 6682.
-rwxr-xr-x | checksetup.pl | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/checksetup.pl b/checksetup.pl index 824802ec6..d324b6314 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -1785,12 +1785,73 @@ if (!($sth->fetchrow_arrayref()->[0])) { # 2000-12-14 New graphing system requires a directory to put the graphs in # This code copied from what happens for the 'data' dir above. +# If the graphs dir is not present, we assume that they have been using +# a Bugzilla with the old data format, and so upgrade their data files. unless (-d 'graphs') { print "Creating graphs directory ...\n"; mkdir 'graphs', 0770; if ($::webservergroup eq "") { chmod 0777, 'graphs'; } + + # Upgrade data format + foreach my $in_file (glob("data/mining/*")) + { + # Don't try and upgrade image files! + if (($in_file =~ /\.gif$/i) || ($in_file =~ /\.png$/i)) { + next; + } + + open(IN, $in_file) or next; + + # Fields in the header + my @declared_fields = (); + + # Fields we changed to half way through by mistake + # This list comes from an old version of collectstats.pl + # This part is only for people who ran later versions of 2.11 (devel) + my @intermediate_fields = qw(DATE UNCONFIRMED NEW ASSIGNED REOPENED + RESOLVED VERIFIED CLOSED); + + # Fields we actually want (matches the current collectstats.pl) + my @out_fields = qw(DATE NEW ASSIGNED REOPENED UNCONFIRMED + VERIFIED CLOSED FIXED INVALID WONTFIX LATER REMIND + DUPLICATE WORKSFORME MOVED); + + while (<IN>) { + if (/^# fields: (.*)\s$/) { + @declared_fields = map uc, (split /\|/, $1); + print "# fields: ", join('|', @out_fields), "\n"; + } + elsif (/^(\d+\|.*)/) { + my @data = split /\|/, $1; + my %data = (); + if (@data == @declared_fields) { + # old format + for my $i (0 .. $#declared_fields) { + $data{$declared_fields[$i]} = $data[$i]; + } + } + elsif (@data == @intermediate_fields) { + # Must have changed over at this point + for my $i (0 .. $#intermediate_fields) { + $data{$intermediate_fields[$i]} = $data[$i]; + } + } + else { + print "Oh dear, input line $. of $in_file had " . scalar(@data) . " fields\n"; + print "This was unexpected. You may want to check your data files.\n"; + } + + print join('|', map { $data{$_} || "" } @out_fields), "\n"; + } + else { + print; + } + } + + close(IN); + } } |