Commit dce1dd61 authored by jocuri%softhome.net's avatar jocuri%softhome.net

Patch for bug 274428: Make checksetup.pl fixup flagtypes with spaces or commas;…

Patch for bug 274428: Make checksetup.pl fixup flagtypes with spaces or commas; patch by Nick.Barnes@pobox.com, r=wurblzap (Marc), a=justdave.
parent aaa60459
...@@ -3854,6 +3854,54 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) { ...@@ -3854,6 +3854,54 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) {
print "done.\n"; 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 # 2002-11-24 - bugreport@peshkin.net - bug 147275
# #
# If group_control_map is empty, backward-compatbility # If group_control_map is empty, backward-compatbility
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment