aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-03-22 17:01:22 +0000
committermkanat%kerio.com <>2005-03-22 17:01:22 +0000
commitd8e58467c5594282ccf42356636d5ac67f1e64e9 (patch)
treef7677162479e50cb6b5a8a27b39bb819b187c421 /editgroups.cgi
parentBug 286689: Cross-DB bz_add_index and bz_drop_index (Part of Bug 285111) (diff)
downloadbugzilla-d8e58467c5594282ccf42356636d5ac67f1e64e9.tar.gz
bugzilla-d8e58467c5594282ccf42356636d5ac67f1e64e9.tar.bz2
bugzilla-d8e58467c5594282ccf42356636d5ac67f1e64e9.zip
Bug 287138: INSERT IGNORE is not ANSI SQL
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=justdave
Diffstat (limited to 'editgroups.cgi')
-rwxr-xr-xeditgroups.cgi19
1 files changed, 12 insertions, 7 deletions
diff --git a/editgroups.cgi b/editgroups.cgi
index c352908bb..88099b543 100755
--- a/editgroups.cgi
+++ b/editgroups.cgi
@@ -57,19 +57,24 @@ sub RederiveRegexp ($$)
my $gid = shift;
my $dbh = Bugzilla->dbh;
my $sth = $dbh->prepare("SELECT userid, login_name FROM profiles");
- my $sthadd = $dbh->prepare("INSERT IGNORE INTO user_group_map
- (user_id, group_id, grant_type, isbless)
- VALUES (?, ?, ?, 0)");
+ my $sthqry = $dbh->prepare("SELECT 1 FROM user_group_map
+ WHERE user_id = ? AND group_id = ?
+ AND grant_type = ? and isbless = 0");
+ my $sthadd = $dbh->prepare("INSERT INTO user_group_map
+ (user_id, group_id, grant_type, isbless)
+ VALUES (?, ?, ?, 0)");
my $sthdel = $dbh->prepare("DELETE FROM user_group_map
- WHERE user_id = ? AND group_id = ?
- AND grant_type = ? and isbless = 0");
+ WHERE user_id = ? AND group_id = ?
+ AND grant_type = ? and isbless = 0");
$sth->execute();
while (my ($uid, $login) = $sth->fetchrow_array()) {
+ my $present = $dbh->selectrow_array($sthqry, undef,
+ $uid, $gid, GRANT_REGEXP);
if (($regexp =~ /\S+/) && ($login =~ m/$regexp/i))
{
- $sthadd->execute($uid, $gid, GRANT_REGEXP);
+ $sthadd->execute($uid, $gid, GRANT_REGEXP) unless $present;
} else {
- $sthdel->execute($uid, $gid, GRANT_REGEXP);
+ $sthdel->execute($uid, $gid, GRANT_REGEXP) if $present;
}
}
}