summaryrefslogtreecommitdiffstats
path: root/extensions/TrackingFlags/lib/Flag.pm
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/TrackingFlags/lib/Flag.pm')
-rw-r--r--extensions/TrackingFlags/lib/Flag.pm19
1 files changed, 12 insertions, 7 deletions
diff --git a/extensions/TrackingFlags/lib/Flag.pm b/extensions/TrackingFlags/lib/Flag.pm
index 26780a2b1..29f81669d 100644
--- a/extensions/TrackingFlags/lib/Flag.pm
+++ b/extensions/TrackingFlags/lib/Flag.pm
@@ -215,13 +215,6 @@ sub remove_from_db {
my $self = shift;
my $dbh = Bugzilla->dbh;
- # Check to see if bug activity table has records
- my $has_activity = $dbh->selectrow_array("SELECT COUNT(*) FROM bugs_activity
- WHERE fieldid = ?", undef, $self->id);
- if ($has_activity) {
- ThrowUserError('tracking_flag_has_activity', { flag => $self });
- }
-
# Check to see if tracking_flags_bugs table has records
if ($self->bug_count) {
ThrowUserError('tracking_flag_has_contents', { flag => $self });
@@ -234,6 +227,7 @@ sub remove_from_db {
eval {
$dbh->bz_start_transaction();
+ $dbh->do('DELETE FROM bugs_activity WHERE fieldid = ?', undef, $self->id);
$dbh->do('DELETE FROM fielddefs WHERE name = ?', undef, $self->name);
$dbh->bz_commit_transaction();
@@ -407,6 +401,17 @@ sub bug_count {
undef, $self->flag_id);
}
+sub activity_count {
+ my ($self) = @_;
+ return $self->{'activity_count'} if defined $self->{'activity_count'};
+ my $dbh = Bugzilla->dbh;
+ return $self->{'activity_count'} = scalar $dbh->selectrow_array("
+ SELECT COUNT(bug_id)
+ FROM bugs_activity
+ WHERE fieldid = ?",
+ undef, $self->id);
+}
+
######################################
# Compatibility with Bugzilla::Field #
######################################