diff options
author | Byron Jones <bjones@mozilla.com> | 2014-03-04 08:50:54 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2014-03-04 08:50:54 +0100 |
commit | 9193214274889f2b7636146e72d8200e9bfaeb7b (patch) | |
tree | e570cc86aa8df53dd0e7e9d902d88450c5dc25c7 /Bugzilla/Classification.pm | |
parent | 75eaf0d6c8ecf764d73cb870e504e84826d44751 (diff) | |
download | bugzilla-9193214274889f2b7636146e72d8200e9bfaeb7b.tar.gz bugzilla-9193214274889f2b7636146e72d8200e9bfaeb7b.tar.xz |
Bug 966180: backport bug 956233 to bmo (enable USE_MEMCACHE on most objects)
Diffstat (limited to 'Bugzilla/Classification.pm')
-rw-r--r-- | Bugzilla/Classification.pm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Bugzilla/Classification.pm b/Bugzilla/Classification.pm index 88ec4eb3b..5d75a6dc6 100644 --- a/Bugzilla/Classification.pm +++ b/Bugzilla/Classification.pm @@ -56,6 +56,7 @@ use constant VALIDATORS => { ############################### #### Constructors ##### ############################### + sub remove_from_db { my $self = shift; my $dbh = Bugzilla->dbh; @@ -63,9 +64,18 @@ sub remove_from_db { ThrowUserError("classification_not_deletable") if ($self->id == 1); $dbh->bz_start_transaction(); + # Reclassify products to the default classification, if needed. - $dbh->do("UPDATE products SET classification_id = 1 - WHERE classification_id = ?", undef, $self->id); + my $product_ids = $dbh->selectcol_arrayref( + 'SELECT id FROM products WHERE classification_id = ?', undef, $self->id); + + if (@$product_ids) { + $dbh->do('UPDATE products SET classification_id = 1 WHERE ' + . $dbh->sql_in('id', $product_ids)); + foreach my $id (@$product_ids) { + Bugzilla->memcached->clear({ table => 'products', id => $id }); + } + } $self->SUPER::remove_from_db(); |