summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-08-03 07:14:39 +0200
committermkanat%bugzilla.org <>2009-08-03 07:14:39 +0200
commite9024051f9835fef0a0ca5223b1ce46098f4a14a (patch)
treea51db145b43790580fc4b8856a714c0eb75803bd /Bugzilla
parenteed377eb471b06932e99c0fdfd226b8eb7af9780 (diff)
downloadbugzilla-e9024051f9835fef0a0ca5223b1ce46098f4a14a.tar.gz
bugzilla-e9024051f9835fef0a0ca5223b1ce46098f4a14a.tar.xz
Bug 405970: Make checksetup.pl not rederive regex groups every time it runs (this was significantly slowing down checksetup.pl on large installations when there was nothing to do)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Install.pm30
-rw-r--r--Bugzilla/Install/DB.pm51
2 files changed, 50 insertions, 31 deletions
diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm
index c469aa857..a32063ca7 100644
--- a/Bugzilla/Install.pm
+++ b/Bugzilla/Install.pm
@@ -185,36 +185,6 @@ sub update_system_groups {
$dbh->do('INSERT INTO group_group_map (grantor_id, member_id)
VALUES (?,?)', undef, $sudo_protect->id, $sudo->id);
}
-
- # Re-evaluate all regexps, to keep them up-to-date.
- my $sth = $dbh->prepare(
- "SELECT profiles.userid, profiles.login_name, groups.id,
- groups.userregexp, user_group_map.group_id
- FROM (profiles CROSS JOIN groups)
- LEFT JOIN user_group_map
- ON user_group_map.user_id = profiles.userid
- AND user_group_map.group_id = groups.id
- AND user_group_map.grant_type = ?
- WHERE userregexp != '' OR user_group_map.group_id IS NOT NULL");
-
- my $sth_add = $dbh->prepare(
- "INSERT INTO user_group_map (user_id, group_id, isbless, grant_type)
- VALUES (?, ?, 0, " . GRANT_REGEXP . ")");
-
- my $sth_del = $dbh->prepare(
- "DELETE FROM user_group_map
- WHERE user_id = ? AND group_id = ? AND isbless = 0
- AND grant_type = " . GRANT_REGEXP);
-
- $sth->execute(GRANT_REGEXP);
- while (my ($uid, $login, $gid, $rexp, $present) = $sth->fetchrow_array()) {
- if ($login =~ m/$rexp/i) {
- $sth_add->execute($uid, $gid) unless $present;
- } else {
- $sth_del->execute($uid, $gid) if $present;
- }
- }
-
}
sub create_default_classification {
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 53f800b82..09b110894 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -415,12 +415,13 @@ sub update_table_definitions {
_fix_attachments_submitter_id_idx();
_copy_attachments_thedata_to_attach_data();
_fix_broken_all_closed_series();
-
# 2005-08-14 bugreport@peshkin.net -- Bug 304583
# Get rid of leftover DERIVED group permissions
use constant GRANT_DERIVED => 1;
$dbh->do("DELETE FROM user_group_map WHERE grant_type = " . GRANT_DERIVED);
+ _rederive_regex_groups();
+
# PUBLIC is a reserved word in Oracle.
$dbh->bz_rename_column('series', 'public', 'is_public');
@@ -2614,6 +2615,54 @@ EOT
} # if (@$broken_nonopen_series)
}
+# This needs to happen at two times: when we upgrade from 2.16 (thus creating
+# user_group_map), and when we kill derived gruops in the DB.
+sub _rederive_regex_groups {
+ my $dbh = Bugzilla->dbh;
+
+ my $regex_groups_exist = $dbh->selectrow_array(
+ "SELECT 1 FROM groups WHERE userregexp = '' " . $dbh->sql_limit(1));
+ return if !$regex_groups_exist;
+
+ my $regex_derivations = $dbh->selectrow_array(
+ 'SELECT 1 FROM user_group_map WHERE grant_type = ' . GRANT_REGEXP
+ . ' ' . $dbh->sql_limit(1));
+ return if $regex_derivations;
+
+ print "Deriving regex group memberships...\n";
+
+ # Re-evaluate all regexps, to keep them up-to-date.
+ my $sth = $dbh->prepare(
+ "SELECT profiles.userid, profiles.login_name, groups.id,
+ groups.userregexp, user_group_map.group_id
+ FROM (profiles CROSS JOIN groups)
+ LEFT JOIN user_group_map
+ ON user_group_map.user_id = profiles.userid
+ AND user_group_map.group_id = groups.id
+ AND user_group_map.grant_type = ?
+ WHERE userregexp != '' OR user_group_map.group_id IS NOT NULL");
+
+ my $sth_add = $dbh->prepare(
+ "INSERT INTO user_group_map (user_id, group_id, isbless, grant_type)
+ VALUES (?, ?, 0, " . GRANT_REGEXP . ")");
+
+ my $sth_del = $dbh->prepare(
+ "DELETE FROM user_group_map
+ WHERE user_id = ? AND group_id = ? AND isbless = 0
+ AND grant_type = " . GRANT_REGEXP);
+
+ $sth->execute(GRANT_REGEXP);
+ while (my ($uid, $login, $gid, $rexp, $present) =
+ $sth->fetchrow_array())
+ {
+ if ($login =~ m/$rexp/i) {
+ $sth_add->execute($uid, $gid) unless $present;
+ } else {
+ $sth_del->execute($uid, $gid) if $present;
+ }
+ }
+}
+
sub _clean_control_characters_from_short_desc {
my $dbh = Bugzilla->dbh;