From: lpsolit%gmail.com <> Date: Sat, 25 Jun 2005 19:15:19 +0000 (+0000) Subject: Bug 277454: Bugs in inactivated groups don't show padlocks on the buglist - Patch... X-Git-Tag: bugzilla-2.18.2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50cc0947d52e4fc9f1a5924a1de00b141fd293cb;p=thirdparty%2Fbugzilla.git Bug 277454: Bugs in inactivated groups don't show padlocks on the buglist - Patch by Marc Schumann r=LpSolit a=justdave --- diff --git a/checksetup.pl b/checksetup.pl index 2031f20fc9..7399f5ff77 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -3856,7 +3856,7 @@ if ($mapcnt == 0) { # First, get all the existing products and their groups. $sth = $dbh->prepare("SELECT groups.id, products.id, groups.name, " . "products.name FROM groups, products " . - "WHERE isbuggroup != 0 AND isactive != 0"); + "WHERE isbuggroup != 0"); $sth->execute(); while (my ($groupid, $productid, $groupname, $productname) = $sth->fetchrow_array()) { diff --git a/sanitycheck.cgi b/sanitycheck.cgi index 5f67dbae7f..da5fd58aef 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -20,6 +20,7 @@ # # Contributor(s): Terry Weissman # Matthew Tuck +# Marc Schumann use strict; @@ -73,6 +74,7 @@ sub BugListLinks { Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; +my $dbh = Bugzilla->dbh; # Make sure the user is authorized to access sanitycheck.cgi. Access # is restricted to logged-in users who have "editbugs" privileges, @@ -170,6 +172,71 @@ if (defined $cgi->param('cleangroupsnow')) { "- reduced from $before records to $after records"); } +if (defined $cgi->param('createmissinggroupcontrolmapentries')) { + Status(qq{OK, now creating SHOWN member control entries + for product/group combinations lacking one.}); + + my $na = CONTROLMAPNA; + my $shown = CONTROLMAPSHOWN; + my $insertsth = $dbh->prepare( + qq{INSERT INTO group_control_map ( + group_id, product_id, entry, + membercontrol, othercontrol, canedit + ) + VALUES ( + ?, ?, 0, + $shown, $na, 0 + )}); + my $updatesth = $dbh->prepare(qq{UPDATE group_control_map + SET membercontrol = $shown + WHERE group_id = ? + AND product_id = ?}); + my $counter = 0; + + # Find all group/product combinations used for bugs but not set up + # correctly in group_control_map + my $invalid_combinations = $dbh->selectall_arrayref( + qq{ SELECT bugs.product_id, + bgm.group_id, + gcm.membercontrol, + groups.name, + products.name + FROM bugs + INNER JOIN bug_group_map AS bgm + ON bugs.bug_id = bgm.bug_id + INNER JOIN groups + ON bgm.group_id = groups.id + INNER JOIN products + ON bugs.product_id = products.id + LEFT JOIN group_control_map AS gcm + ON bugs.product_id = gcm.product_id + AND bgm.group_id = gcm.group_id + WHERE COALESCE(gcm.membercontrol, $na) = $na + GROUP BY bugs.product_id, bgm.group_id}); + + foreach (@$invalid_combinations) { + my ($product_id, $group_id, $currentmembercontrol, + $group_name, $product_name) = @$_; + + $counter++; + if (defined($currentmembercontrol)) { + Status(qq{Updating NA/xxx group control + setting for group $group_name to + SHOWN/xxx in product + $product_name.}); + $updatesth->execute($group_id, $product_id); + } + else { + Status(qq{Generating SHOWN/NA group control setting + for group $group_name in product + $product_name.}); + $insertsth->execute($group_id, $product_id); + } + } + + Status("Repaired $counter defective group control settings."); +} + if (defined $cgi->param('rescanallBugMail')) { require Bugzilla::BugMail; @@ -596,8 +663,8 @@ if (defined $cgi->param('rebuildkeywordcache')) { # General bug checks ########################################################################### -sub BugCheck ($$) { - my ($middlesql, $errortext) = @_; +sub BugCheck ($$;$$) { + my ($middlesql, $errortext, $repairparam, $repairtext) = @_; SendSQL("SELECT DISTINCT bugs.bug_id " . "FROM $middlesql " . @@ -612,6 +679,11 @@ sub BugCheck ($$) { if (@badbugs) { Alert("$errortext: " . BugListLinks(@badbugs)); + if ($repairparam) { + $repairtext ||= 'Repair these bugs'; + print qq{$repairtext.}, + '

'; + } } } @@ -705,18 +777,19 @@ BugCheck("bugs INNER JOIN groups ON bug_group_map.group_id = groups.id LEFT JOIN group_control_map ON bugs.product_id = group_control_map.product_id AND bug_group_map.group_id = group_control_map.group_id - WHERE groups.isactive != 0 - AND ((group_control_map.membercontrol = " . CONTROLMAPNA . ") + WHERE ((group_control_map.membercontrol = " . CONTROLMAPNA . ") OR (group_control_map.membercontrol IS NULL))", - "Have groups not permitted for their products"); + 'Have groups not permitted for their products', + 'createmissinggroupcontrolmapentries', + 'Permit the missing groups for the affected products + (set member control to SHOWN)'); BugCheck("bugs INNER JOIN bug_group_map ON bugs.bug_id = bug_group_map.bug_id INNER JOIN groups ON bug_group_map.group_id = groups.id LEFT JOIN group_control_map ON bugs.product_id = group_control_map.product_id AND bug_group_map.group_id = group_control_map.group_id - WHERE groups.isactive != 0 - AND group_control_map.membercontrol = " . CONTROLMAPMANDATORY . " + WHERE group_control_map.membercontrol = " . CONTROLMAPMANDATORY . " AND bug_group_map.group_id IS NULL", "Are missing groups required for their products");