summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@mozilla.com>2014-10-28 06:05:29 +0100
committerByron Jones <glob@mozilla.com>2014-10-28 06:05:29 +0100
commit37bd66c10e4ce1fe0015519d95841d21eb917c34 (patch)
tree06965f741cb4fc4dde8aa8e8b0752b9b3f416a17 /contrib
parent83eac0c239ca39448417d9571d6262565e530baa (diff)
downloadbugzilla-37bd66c10e4ce1fe0015519d95841d21eb917c34.tar.gz
bugzilla-37bd66c10e4ce1fe0015519d95841d21eb917c34.tar.xz
Bug 1087525: fix movecomponents.pl creating duplicate rows in
flag*clusions
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/reorg-tools/movecomponent.pl23
1 files changed, 16 insertions, 7 deletions
diff --git a/contrib/reorg-tools/movecomponent.pl b/contrib/reorg-tools/movecomponent.pl
index bdbfdc976..cb07b84fc 100755
--- a/contrib/reorg-tools/movecomponent.pl
+++ b/contrib/reorg-tools/movecomponent.pl
@@ -101,13 +101,8 @@ $dbh->do("UPDATE bugs SET product_id = ? WHERE component_id = ?",
($new_product->id, $component->id));
# Flags tables
-$dbh->do("UPDATE flaginclusions SET product_id = ? WHERE component_id = ?",
- undef,
- ($new_product->id, $component->id));
-
-$dbh->do("UPDATE flagexclusions SET product_id = ? WHERE component_id = ?",
- undef,
- ($new_product->id, $component->id));
+fix_flags('flaginclusions', $new_product, $component);
+fix_flags('flagexclusions', $new_product, $component);
# Components
$dbh->do("UPDATE components SET product_id = ? WHERE id = ?",
@@ -143,3 +138,17 @@ $dbh->bz_commit_transaction();
# It's complex to determine which items now need to be flushed from memcached.
# As this is expected to be a rare event, we just flush the entire cache.
Bugzilla->memcached->clear_all();
+
+sub fix_flags {
+ my ($table, $new_product, $component) = @_;
+ my $dbh = Bugzilla->dbh;
+
+ my $type_ids = $dbh->selectcol_arrayref("SELECT DISTINCT type_id FROM $table WHERE component_id = ?",
+ undef,
+ $component->id);
+ $dbh->do("DELETE FROM $table WHERE component_id = ?", undef, $component->id);
+ foreach my $type_id (@$type_ids) {
+ $dbh->do("INSERT INTO $table (type_id, product_id, component_id) VALUES (?, ?, ?)",
+ undef, ($type_id, $new_product->id, $component->id));
+ }
+}