From 9193214274889f2b7636146e72d8200e9bfaeb7b Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 4 Mar 2014 15:50:54 +0800 Subject: Bug 966180: backport bug 956233 to bmo (enable USE_MEMCACHE on most objects) --- Bugzilla/Classification.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Bugzilla/Classification.pm') 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(); -- cgit v1.2.3-24-g4f1b