summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2011-08-17 13:05:31 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2011-08-17 13:05:31 +0200
commit589632e9d5d35c25c932aafa164feb92c26f5e3d (patch)
treea91df977bac1818f8a70fb7e758576a294a7221e /Bugzilla
parent664920c7dd532d2243538b1fd3705a72e8d496e6 (diff)
downloadbugzilla-589632e9d5d35c25c932aafa164feb92c26f5e3d.tar.gz
bugzilla-589632e9d5d35c25c932aafa164feb92c26f5e3d.tar.xz
Bug 661476: sanitycheck.pl should check if all products have components defined.
Also, creating a new product from the web UI asks you to create a component too. r=glob a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Component.pm5
-rw-r--r--Bugzilla/Version.pm9
2 files changed, 14 insertions, 0 deletions
diff --git a/Bugzilla/Component.pm b/Bugzilla/Component.pm
index 215119715..ceca7e794 100644
--- a/Bugzilla/Component.pm
+++ b/Bugzilla/Component.pm
@@ -155,6 +155,11 @@ sub remove_from_db {
$dbh->bz_start_transaction();
+ # Products must have at least one component.
+ if (scalar(@{$self->product->components}) == 1) {
+ ThrowUserError('component_is_last', { comp => $self });
+ }
+
if ($self->bug_count) {
if (Bugzilla->params->{'allowbugdeletion'}) {
require Bugzilla::Bug;
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();
}
###############################