summaryrefslogtreecommitdiffstats
path: root/checksetup.pl
diff options
context:
space:
mode:
authorjocuri%softhome.net <>2004-12-14 10:29:44 +0100
committerjocuri%softhome.net <>2004-12-14 10:29:44 +0100
commitdce1dd615c71bcf608f597f9fda8d7ed6fd1f541 (patch)
tree42119f3fd5c35ddf60465e3f1a19d61b7daf3284 /checksetup.pl
parentaaa60459fe10d79ec2d6cb9bac06b8eb8299ee83 (diff)
downloadbugzilla-dce1dd615c71bcf608f597f9fda8d7ed6fd1f541.tar.gz
bugzilla-dce1dd615c71bcf608f597f9fda8d7ed6fd1f541.tar.xz
Patch for bug 274428: Make checksetup.pl fixup flagtypes with spaces or commas; patch by Nick.Barnes@pobox.com, r=wurblzap (Marc), a=justdave.
Diffstat (limited to 'checksetup.pl')
-rwxr-xr-xchecksetup.pl48
1 files changed, 48 insertions, 0 deletions
diff --git a/checksetup.pl b/checksetup.pl
index 7b2ec0fef..681d9bde3 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -3854,6 +3854,54 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) {
print "done.\n";
}
+# 2004-12-13 Nick.Barnes@pobox.com bug 262268
+# Check flag type names for spaces and commas, and rename them.
+if (TableExists("flagtypes")) {
+ print "Checking flag type names for spaces and commas...\n";
+
+ # Get names and IDs which are broken.
+ $sth = $dbh->prepare("SELECT name, id FROM flagtypes");
+ $sth->execute();
+
+ my %flagtypes;
+ my @badflagnames;
+
+ while (my ($name, $id) = $sth->fetchrow_array()) {
+ $flagtypes{$name} = $id;
+ if ($name =~ /[ ,]/) {
+ push(@badflagnames, $name);
+ }
+ }
+ if (@badflagnames) {
+ my ($flagname, $tryflagname);
+ my $sth = $dbh->prepare("UPDATE flagtypes SET name = ? WHERE id = ?");
+ foreach $flagname (@badflagnames) {
+ print " Bad flag type name \"$flagname\" ...\n";
+ ($tryflagname = $flagname) =~ tr/ ,/__/;
+ while (defined($flagtypes{$tryflagname})) {
+ print " ... can't rename as \"$tryflagname\" ...\n";
+ $tryflagname .= "'";
+ if (length($tryflagname) > 50) {
+ my $lastchanceflagname = (substr $tryflagname, 0, 47) . '...';
+ if (defined($flagtypes{$lastchanceflagname})) {
+ print " ... last attempt as \"$lastchanceflagname\" still failed.'\n";
+ print "Rename the flag by hand and run checksetup.pl again.\n";
+ die("Bad flag type name $flagname");
+ }
+ $tryflagname = $lastchanceflagname;
+ }
+ }
+ $sth->execute($tryflagname, $flagtypes{$flagname});
+ print " renamed flag type \"$flagname\" as \"$tryflagname\"\n";
+ $flagtypes{$tryflagname} = $flagtypes{$flagname};
+ delete $flagtypes{$flagname};
+ }
+ print "... done.\n";
+ } else {
+ print "... all flag type names are good.\n";
+ }
+}
+
# 2002-11-24 - bugreport@peshkin.net - bug 147275
#
# If group_control_map is empty, backward-compatbility