summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-06-10 07:47:32 +0200
committerByron Jones <glob@mozilla.com>2014-06-10 07:47:46 +0200
commitd9b38fd554ae02a645746c13d1f2ca5d743026f3 (patch)
tree628f2e58ef18f86fb9f943c11aeecce271748f5e /extensions
parentf0cab2479e25ab0ed36a8bf256406d80b21ddb19 (diff)
downloadbugzilla-d9b38fd554ae02a645746c13d1f2ca5d743026f3.tar.gz
bugzilla-d9b38fd554ae02a645746c13d1f2ca5d743026f3.tar.xz
Bug 1022500: cloning a firefox tracking flags throws "The component named 'Template::Document=HASH(0x7f7ffacdb4c8)' does not exist. "
Diffstat (limited to 'extensions')
-rw-r--r--extensions/ComponentWatching/Extension.pm61
-rw-r--r--extensions/ComponentWatching/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl23
-rw-r--r--extensions/TrackingFlags/Extension.pm61
-rw-r--r--extensions/TrackingFlags/lib/Admin.pm5
-rw-r--r--extensions/TrackingFlags/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl23
-rw-r--r--extensions/TrackingFlags/template/en/default/hook/global/code-error-errors.html.tmpl3
6 files changed, 174 insertions, 2 deletions
diff --git a/extensions/ComponentWatching/Extension.pm b/extensions/ComponentWatching/Extension.pm
index addbaba70..f85e0010c 100644
--- a/extensions/ComponentWatching/Extension.pm
+++ b/extensions/ComponentWatching/Extension.pm
@@ -530,4 +530,65 @@ sub _addDefaultSettings {
}
}
+sub reorg_move_component {
+ my ($self, $args) = @_;
+ my $new_product = $args->{new_product};
+ my $component = $args->{component};
+
+ Bugzilla->dbh->do(
+ "UPDATE component_watch SET product_id=? WHERE component_id=?",
+ undef,
+ $new_product->id, $component->id,
+ );
+}
+
+sub sanitycheck_check {
+ my ($self, $args) = @_;
+ my $status = $args->{status};
+
+ $status->('component_watching_check');
+
+ my ($count) = Bugzilla->dbh->selectrow_array("
+ SELECT COUNT(*)
+ FROM component_watch
+ INNER JOIN components ON components.id = component_watch.component_id
+ WHERE component_watch.product_id <> components.product_id
+ ");
+ if ($count) {
+ $status->('component_watching_alert', undef, 'alert');
+ $status->('component_watching_repair');
+ }
+}
+
+sub sanitycheck_repair {
+ my ($self, $args) = @_;
+ return unless Bugzilla->cgi->param('component_watching_repair');
+
+ my $status = $args->{'status'};
+ my $dbh = Bugzilla->dbh;
+ $status->('component_watching_repairing');
+
+ my $rows = $dbh->selectall_arrayref("
+ SELECT DISTINCT component_watch.product_id AS bad_product_id,
+ components.product_id AS good_product_id,
+ component_watch.component_id
+ FROM component_watch
+ INNER JOIN components ON components.id = component_watch.component_id
+ WHERE component_watch.product_id <> components.product_id
+ ",
+ { Slice => {} }
+ );
+ foreach my $row (@$rows) {
+ $dbh->do("
+ UPDATE component_watch
+ SET product_id=?
+ WHERE product_id=? AND component_id=?
+ ", undef,
+ $row->{good_product_id},
+ $row->{bad_product_id},
+ $row->{component_id},
+ );
+ }
+}
+
__PACKAGE__->NAME;
diff --git a/extensions/ComponentWatching/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl b/extensions/ComponentWatching/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl
new file mode 100644
index 000000000..c22ffacaa
--- /dev/null
+++ b/extensions/ComponentWatching/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl
@@ -0,0 +1,23 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% IF san_tag == "component_watching_repair" %]
+ <a href="sanitycheck.cgi?component_watching_repair=1&amp;token=
+ [%- issue_hash_token(['sanitycheck']) FILTER uri %]"
+ >Repair invalid product_id values in the component_watch table</a>
+
+[% ELSIF san_tag == "component_watching_check" %]
+ Checking component_watch table for bad values of product_id.
+
+[% ELSIF san_tag == "component_watching_alert" %]
+ Bad values for product_id found in the component_watch table.
+
+[% ELSIF san_tag == "component_watching_repairing" %]
+ OK, now fixing bad product_id values in the component_watch table.
+
+[% END %]
diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm
index 7d8f8c401..3ba9e768b 100644
--- a/extensions/TrackingFlags/Extension.pm
+++ b/extensions/TrackingFlags/Extension.pm
@@ -657,4 +657,65 @@ sub quicksearch_map {
}
}
+sub reorg_move_component {
+ my ($self, $args) = @_;
+ my $new_product = $args->{new_product};
+ my $component = $args->{component};
+
+ Bugzilla->dbh->do(
+ "UPDATE tracking_flags_visibility SET product_id=? WHERE component_id=?",
+ undef,
+ $new_product->id, $component->id,
+ );
+}
+
+sub sanitycheck_check {
+ my ($self, $args) = @_;
+ my $status = $args->{status};
+
+ $status->('tracking_flags_check');
+
+ my ($count) = Bugzilla->dbh->selectrow_array("
+ SELECT COUNT(*)
+ FROM tracking_flags_visibility
+ INNER JOIN components ON components.id = tracking_flags_visibility.component_id
+ WHERE tracking_flags_visibility.product_id <> components.product_id
+ ");
+ if ($count) {
+ $status->('tracking_flags_alert', undef, 'alert');
+ $status->('tracking_flags_repair');
+ }
+}
+
+sub sanitycheck_repair {
+ my ($self, $args) = @_;
+ return unless Bugzilla->cgi->param('tracking_flags_repair');
+
+ my $status = $args->{'status'};
+ my $dbh = Bugzilla->dbh;
+ $status->('tracking_flags_repairing');
+
+ my $rows = $dbh->selectall_arrayref("
+ SELECT DISTINCT tracking_flags_visibility.product_id AS bad_product_id,
+ components.product_id AS good_product_id,
+ tracking_flags_visibility.component_id
+ FROM tracking_flags_visibility
+ INNER JOIN components ON components.id = tracking_flags_visibility.component_id
+ WHERE tracking_flags_visibility.product_id <> components.product_id
+ ",
+ { Slice => {} }
+ );
+ foreach my $row (@$rows) {
+ $dbh->do("
+ UPDATE tracking_flags_visibility
+ SET product_id=?
+ WHERE product_id=? AND component_id=?
+ ", undef,
+ $row->{good_product_id},
+ $row->{bad_product_id},
+ $row->{component_id},
+ );
+ }
+}
+
__PACKAGE__->NAME;
diff --git a/extensions/TrackingFlags/lib/Admin.pm b/extensions/TrackingFlags/lib/Admin.pm
index b72416819..389acde2c 100644
--- a/extensions/TrackingFlags/lib/Admin.pm
+++ b/extensions/TrackingFlags/lib/Admin.pm
@@ -263,7 +263,10 @@ sub _validate {
if ($visibility->{component} ne '') {
$visibility->{component_obj} = Bugzilla::Component->new({ product => $visibility->{product_obj},
name => $visibility->{component} })
- || ThrowCodeError('tracking_flags_invalid_component', { component => $visibility->{component} });
+ || ThrowCodeError('tracking_flags_invalid_component', {
+ product => $visibility->{product},
+ component_name => $visibility->{component},
+ });
}
}
diff --git a/extensions/TrackingFlags/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl b/extensions/TrackingFlags/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl
new file mode 100644
index 000000000..71ef63c11
--- /dev/null
+++ b/extensions/TrackingFlags/template/en/default/hook/admin/sanitycheck/messages-statuses.html.tmpl
@@ -0,0 +1,23 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% IF san_tag == "tracking_flags_repair" %]
+ <a href="sanitycheck.cgi?tracking_flags_repair=1&amp;token=
+ [%- issue_hash_token(['sanitycheck']) FILTER uri %]"
+ >Repair invalid product_id values in the tracking_flags_visibility table</a>
+
+[% ELSIF san_tag == "tracking_flags_check" %]
+ Checking tracking_flags_visibility table for bad values of product_id.
+
+[% ELSIF san_tag == "tracking_flags_alert" %]
+ Bad values for product_id found in the tracking_flags_visibility table.
+
+[% ELSIF san_tag == "tracking_flags_repairing" %]
+ OK, now fixing bad product_id values in the tracking_flags_visibility table.
+
+[% END %]
diff --git a/extensions/TrackingFlags/template/en/default/hook/global/code-error-errors.html.tmpl b/extensions/TrackingFlags/template/en/default/hook/global/code-error-errors.html.tmpl
index 2d462ebaf..d656aac92 100644
--- a/extensions/TrackingFlags/template/en/default/hook/global/code-error-errors.html.tmpl
+++ b/extensions/TrackingFlags/template/en/default/hook/global/code-error-errors.html.tmpl
@@ -12,7 +12,8 @@
[% ELSIF error == "tracking_flags_invalid_component" %]
[% title = "Invalid Component" %]
- The component named '[% component FILTER html %]' does not exist.
+ The component named '[% component_name FILTER html %]' does not exist in the
+ product '[% product FILTER html %]'.
[% ELSIF error == "tracking_flags_invalid_item_id" %]
[% title = "Invalid " _ item _ " ID" %]