Commit 84982d8b authored by Tiago Mello's avatar Tiago Mello

Bug 722580: Move 'ReviewBoard' and 'Rietveld' BugUrl sub-classes

to a new 'MoreBugUrl' extension. r/a=LpSolit
parent 8cf99992
......@@ -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
......
......@@ -389,6 +389,21 @@ the summary line).
=back
=head2 bug_url_sub_classes
Allows you to add more L<Bugzilla::BugUrl> sub-classes.
See the C<MoreBugUrl> extension to see how things work.
Params:
=over
=item C<sub_classes> - An arrayref of strings which represent L<Bugzilla::BugUrl>
sub-classes.
=back
=head2 buglist_columns
This happens in L<Bugzilla::Search/COLUMNS>, which determines legal bug
......
# 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;
# 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;
......@@ -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);
......
......@@ -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);
......
[%# 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.
#%]
<li>A Review Board review request.</li>
<li>An issue in a Rietveld installation.</li>
......@@ -254,8 +254,7 @@
<li>A ticket in a Trac installation.</li>
<li>A b[% %]ug in a MantisBT installation.</li>
<li>A b[% %]ug on sourceforge.net.</li>
<li>A Review Board review request.</li>
<li>An issue in a Rietveld installation.</li>
[% Hook.process('bug_url_invalid_tracker') %]
</ul>
[% ELSIF reason == 'id' %]
There is no valid [% terms.bug %] id in that URL.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment