Deleting a product does not remove its entries from the 'Series' table.

RESOLVED FIXED in Bugzilla 3.6

Status

()

task
RESOLVED FIXED
11 years ago
10 years ago

People

(Reporter: LpSolit, Assigned: LpSolit)

Tracking

2.18
Bugzilla 3.6
Dependency tree / graph
Bug Flags:
approval +

Details

Attachments

(1 attachment)

+++ This bug was initially created as a clone of Bug #247936 +++

In bug 247936, we fixed the crash by making sure the series was not already in the DB when recreating the same product or component again. There has been some discussion about why the series have not been deleted at the same time as the product or component themselves.

The trend seems to be that deleting a product should also delete related series (and if you don't want to loose the data, don't delete the product).

Everybody has been CC'ed as I cloned the bug.
Now that bug 302542 is fixed, all I need to do is to invoke $series->remove_from_db() if the admin decides to remove related series when deleting a product.
Assignee: administration → LpSolit
Severity: normal → enhancement
Status: NEW → ASSIGNED
No longer depends on: 230254
Target Milestone: --- → Bugzilla 3.6
Posted patch patch, v1Splinter Review
Attachment #413425 - Flags: review?(gerv)
Comment on attachment 413425 [details] [diff] [review]
patch, v1

r=gerv.

Gerv
Attachment #413425 - Flags: review?(gerv) → review+
Flags: approval+
Checking in editproducts.cgi;
/cvsroot/mozilla/webtools/bugzilla/editproducts.cgi,v  <--  editproducts.cgi
new revision: 1.151; previous revision: 1.150
done
Checking in Bugzilla/Product.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Product.pm,v  <--  Product.pm
new revision: 1.41; previous revision: 1.40
done
Checking in template/en/default/admin/products/confirm-delete.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/admin/products/confirm-delete.html.tmpl,v  <--  confirm-delete.html.tmpl
new revision: 1.13; previous revision: 1.12
done
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Keywords: relnote
Trying to delete the test product from a fresh install (from bzr trunk), yield the following error:

DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 [for Statement "DELETE FROM series WHERE  series_id IN () "] at Bugzilla/Product.pm line 301
	Bugzilla::Product::remove_from_db('Bugzilla::Product=HASH(0x997a3e8)', 'HASH(0x9830598)') called at /home/sbodo/workspace/foss/bzr/mozilla.org/bugzilla/editproducts.cgi line 235

So the delete statement should be executed only when the previous select yields some result in $series_ids:

$dbh->do('DELETE FROM series WHERE ' . $dbh->sql_in('series_id', $series_ids)) if $series_ids;
=== modified file 'Bugzilla/Product.pm'
--- Bugzilla/Product.pm 2010-02-15 23:22:55 +0000
+++ Bugzilla/Product.pm 2010-02-20 12:58:44 +0000
@@ -298,7 +298,7 @@
                                      WHERE series_categories.name = ?',
                                     undef, $self->name);

-        $dbh->do('DELETE FROM series WHERE ' . $dbh->sql_in('series_id', $series_ids));
+        $dbh->do('DELETE FROM series WHERE ' . $dbh->sql_in('series_id', $series_ids)) if @{$series_ids};

         # If no subcategory uses this product name, completely purge it.
         my $in_use =




(In reply to comment #5)
> Trying to delete the test product from a fresh install (from bzr trunk), yield
> the following error:
> 
> DBD::mysql::db do failed: You have an error in your SQL syntax; check the
> manual that corresponds to your MySQL server version for the right syntax to
> use near ')' at line 1 [for Statement "DELETE FROM series WHERE  series_id IN
> () "] at Bugzilla/Product.pm line 301
>     Bugzilla::Product::remove_from_db('Bugzilla::Product=HASH(0x997a3e8)',
> 'HASH(0x9830598)') called at
> /home/sbodo/workspace/foss/bzr/mozilla.org/bugzilla/editproducts.cgi line 235
> 
> So the delete statement should be executed only when the previous select yields
> some result in $series_ids:
> 
> $dbh->do('DELETE FROM series WHERE ' . $dbh->sql_in('series_id', $series_ids))
> if $series_ids;
(In reply to comment #6)
> === modified file 'Bugzilla/Product.pm'
> --- Bugzilla/Product.pm 2010-02-15 23:22:55 +0000
> +++ Bugzilla/Product.pm 2010-02-20 12:58:44 +0000

Bodo-Merle Sandor, could you please file a separate bug, attach this patch and ask me for review? If not, I can file it and attach your patch myself, if you prefer.
Blocks: 547428
Added to the release notes in bug 547466.
Keywords: relnote
You need to log in before you can comment on or make changes to this bug.