From: Tiago Mello Date: Sun, 19 Feb 2012 17:36:22 +0000 (-0200) Subject: Bug 722580: Move 'ReviewBoard' and 'Rietveld' BugUrl sub-classes X-Git-Tag: bugzilla-4.3.1~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84982d8b04f6232d4eaa38fde78e8bfa67d496bb;p=thirdparty%2Fbugzilla.git Bug 722580: Move 'ReviewBoard' and 'Rietveld' BugUrl sub-classes to a new 'MoreBugUrl' extension. r/a=LpSolit --- diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 99d46bd247..888b11398f 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -12,6 +12,7 @@ use base qw(Bugzilla::Object); use Bugzilla::Util; use Bugzilla::Error; use Bugzilla::Constants; +use Bugzilla::Hook; use URI::QueryParam; @@ -56,8 +57,6 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::Trac Bugzilla::BugUrl::MantisBT Bugzilla::BugUrl::SourceForge - Bugzilla::BugUrl::ReviewBoard - Bugzilla::BugUrl::Rietveld ); ############################### @@ -121,8 +120,12 @@ sub should_handle { sub class_for { my ($class, $value) = @_; + my @sub_classes = $class->SUB_CLASSES; + Bugzilla::Hook::process("bug_url_sub_classes", + { sub_classes => \@sub_classes }); + my $uri = URI->new($value); - foreach my $subclass ($class->SUB_CLASSES) { + foreach my $subclass (@sub_classes) { eval "use $subclass"; die $@ if $@; return wantarray ? ($subclass, $uri) : $subclass diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index fe4f0860e6..17023f8f5a 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -389,6 +389,21 @@ the summary line). =back +=head2 bug_url_sub_classes + +Allows you to add more L sub-classes. + +See the C extension to see how things work. + +Params: + +=over + +=item C - An arrayref of strings which represent L +sub-classes. + +=back + =head2 buglist_columns This happens in L, which determines legal bug diff --git a/extensions/MoreBugUrl/Config.pm b/extensions/MoreBugUrl/Config.pm new file mode 100644 index 0000000000..b5af9c00ef --- /dev/null +++ b/extensions/MoreBugUrl/Config.pm @@ -0,0 +1,19 @@ +# 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. + +package Bugzilla::Extension::MoreBugUrl; +use strict; + +use constant NAME => 'MoreBugUrl'; + +use constant REQUIRED_MODULES => [ +]; + +use constant OPTIONAL_MODULES => [ +]; + +__PACKAGE__->NAME; diff --git a/extensions/MoreBugUrl/Extension.pm b/extensions/MoreBugUrl/Extension.pm new file mode 100644 index 0000000000..7153165856 --- /dev/null +++ b/extensions/MoreBugUrl/Extension.pm @@ -0,0 +1,43 @@ +# 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. + +package Bugzilla::Extension::MoreBugUrl; +use strict; +use base qw(Bugzilla::Extension); + +use constant MORE_SUB_CLASSES => qw( + Bugzilla::Extension::MoreBugUrl::ReviewBoard + Bugzilla::Extension::MoreBugUrl::Rietveld +); + +# We need to update bug_see_also table because both +# Rietveld and ReviewBoard were originally under Bugzilla/BugUrl/. +sub install_update_db { + my $dbh = Bugzilla->dbh; + + my $should_rename = $dbh->selectrow_array( + q{SELECT 1 FROM bug_see_also + WHERE class IN ('Bugzilla::BugUrl::Rietveld', + 'Bugzilla::BugUrl::ReviewBoard')}); + + if ($should_rename) { + my $sth = $dbh->prepare('UPDATE bug_see_also SET class = ? + WHERE class = ?'); + $sth->execute('Bugzilla::Extension::MoreBugUrl::ReviewBoard', + 'Bugzilla::BugUrl::ReviewBoard'); + + $sth->execute('Bugzilla::Extension::MoreBugUrl::Rietveld', + 'Bugzilla::BugUrl::Rietveld'); + } +} + +sub bug_url_sub_classes { + my ($self, $args) = @_; + push @{ $args->{sub_classes} }, MORE_SUB_CLASSES; +} + +__PACKAGE__->NAME; diff --git a/extensions/MoreBugUrl/disabled b/extensions/MoreBugUrl/disabled new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Bugzilla/BugUrl/ReviewBoard.pm b/extensions/MoreBugUrl/lib/ReviewBoard.pm similarity index 95% rename from Bugzilla/BugUrl/ReviewBoard.pm rename to extensions/MoreBugUrl/lib/ReviewBoard.pm index 3c1ed56ba5..7628dd3141 100644 --- a/Bugzilla/BugUrl/ReviewBoard.pm +++ b/extensions/MoreBugUrl/lib/ReviewBoard.pm @@ -5,7 +5,7 @@ # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. -package Bugzilla::BugUrl::ReviewBoard; +package Bugzilla::Extension::MoreBugUrl::ReviewBoard; use strict; use base qw(Bugzilla::BugUrl); diff --git a/Bugzilla/BugUrl/Rietveld.pm b/extensions/MoreBugUrl/lib/Rietveld.pm similarity index 96% rename from Bugzilla/BugUrl/Rietveld.pm rename to extensions/MoreBugUrl/lib/Rietveld.pm index 9baf85d8d7..0c52892e24 100644 --- a/Bugzilla/BugUrl/Rietveld.pm +++ b/extensions/MoreBugUrl/lib/Rietveld.pm @@ -5,7 +5,7 @@ # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. -package Bugzilla::BugUrl::Rietveld; +package Bugzilla::Extension::MoreBugUrl::Rietveld; use strict; use base qw(Bugzilla::BugUrl); diff --git a/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl b/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl new file mode 100644 index 0000000000..e0cf6be8e3 --- /dev/null +++ b/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl @@ -0,0 +1,10 @@ +[%# 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. + #%] + +
  • A Review Board review request.
  • +
  • An issue in a Rietveld installation.
  • diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index fdd2fb980d..7408a1a05e 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -254,8 +254,7 @@
  • A ticket in a Trac installation.
  • A b[% %]ug in a MantisBT installation.
  • A b[% %]ug on sourceforge.net.
  • -
  • A Review Board review request.
  • -
  • An issue in a Rietveld installation.
  • + [% Hook.process('bug_url_invalid_tracker') %] [% ELSIF reason == 'id' %] There is no valid [% terms.bug %] id in that URL.