aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortravis%sedsystems.ca <>2005-01-28 03:56:34 +0000
committertravis%sedsystems.ca <>2005-01-28 03:56:34 +0000
commit8d4f43f154fd00b64234a64dc50394f8633bdd96 (patch)
tree5c9e7720f23fd9715930eb662f929f4b9bbe6f9f
parente749f7333f0e2844f17d9b9011e1a13ed00ad121 (diff)
downloadbugs-8d4f43f154fd00b64234a64dc50394f8633bdd96.tar
bugs-8d4f43f154fd00b64234a64dc50394f8633bdd96.tar.gz
bugs-8d4f43f154fd00b64234a64dc50394f8633bdd96.tar.bz2
bugs-8d4f43f154fd00b64234a64dc50394f8633bdd96.tar.xz
bugs-8d4f43f154fd00b64234a64dc50394f8633bdd96.zip
Bug 278010 : checksetup.pl should fix empty group names
Patch by Nick.Barnes@pobox.com r=wurblzap a=myk
-rwxr-xr-xchecksetup.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/checksetup.pl b/checksetup.pl
index a01d0962a..6bbedaaea 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -4660,6 +4660,35 @@ if (($fielddef = GetFieldDef("logincookies", "lastused")) &&
ChangeFieldType ('logincookies', 'lastused', 'DATETIME NOT NULL');
}
+# 2005-01-12 Nick Barnes <nb@ravenbrook.com> bug 278010
+# Rename any group which has an empty name.
+# Note that there can be at most one such group (because of
+# the SQL index on the name column).
+$sth = $dbh->prepare("SELECT id FROM groups where name = ''");
+$sth->execute();
+my ($emptygroupid) = $sth->fetchrow_array();
+if ($emptygroupid) {
+ # There is a group with an empty name; find a name to rename it
+ # as. Must avoid collisions with existing names. Start with
+ # group_$gid and add _<n> if necessary.
+ my $trycount = 0;
+ my $trygroupname;
+ my $trygroupsth = $dbh->prepare("SELECT id FROM groups where name = ?");
+ do {
+ $trygroupname = "group_$emptygroupid";
+ if ($trycount > 0) {
+ $trygroupname .= "_$trycount";
+ }
+ $trygroupsth->execute($trygroupname);
+ if ($trygroupsth->rows > 0) {
+ $trycount ++;
+ }
+ } while ($trygroupsth->rows > 0);
+ $sth = $dbh->prepare("UPDATE groups SET name = ? WHERE id = $emptygroupid");
+ $sth->execute($trygroupname);
+ print "Group $emptygroupid had an empty name; renamed as '$trygroupname'.\n";
+}
+
#
# Final checks...