summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Version.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Version.pm')
-rw-r--r--Bugzilla/Version.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/Bugzilla/Version.pm b/Bugzilla/Version.pm
index 7f53add13..250c474ca 100644
--- a/Bugzilla/Version.pm
+++ b/Bugzilla/Version.pm
@@ -143,12 +143,21 @@ sub remove_from_db {
my $self = shift;
my $dbh = Bugzilla->dbh;
+ $dbh->bz_start_transaction();
+
+ # Products must have at least one version.
+ if (scalar(@{$self->product->versions}) == 1) {
+ ThrowUserError('version_is_last', { version => $self });
+ }
+
# The version cannot be removed if there are bugs
# associated with it.
if ($self->bug_count) {
ThrowUserError("version_has_bugs", { nb => $self->bug_count });
}
$self->SUPER::remove_from_db();
+
+ $dbh->bz_commit_transaction();
}
###############################