summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2012-01-28 00:39:23 +0100
committerDave Lawrence <dlawrence@mozilla.com>2012-01-28 00:39:23 +0100
commit02414dc53b2f932d0477ef03d3913bc12ff924dd (patch)
tree1d008bd9d44ed7c1fbb42434f61aea7b77e4571b /Bugzilla
parent2fdfa60f167cbbee507351fba19c8e01880d9ae6 (diff)
parenta8fd4c69ba96a7f751859db566bda85142e0beb2 (diff)
downloadbugzilla-02414dc53b2f932d0477ef03d3913bc12ff924dd.tar.gz
bugzilla-02414dc53b2f932d0477ef03d3913bc12ff924dd.tar.xz
merged with bugzilla/4.2
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm7
-rw-r--r--Bugzilla/BugUrl/JIRA.pm2
-rw-r--r--Bugzilla/Install/DB.pm31
3 files changed, 35 insertions, 5 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 2361e7343..5fb4551e4 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -2866,14 +2866,13 @@ sub add_see_also {
$class->check_required_create_fields($params);
my $field_values = $class->run_create_validators($params);
- $uri = $field_values->{value};
- $field_values->{value} = $uri->as_string;
+ my $value = $field_values->{value}->as_string;
+ trick_taint($value);
+ $field_values->{value} = $value;
# We only add the new URI if it hasn't been added yet. URIs are
# case-sensitive, but most of our DBs are case-insensitive, so we do
# this check case-insensitively.
- my $value = $uri->as_string;
-
if (!grep { lc($_->name) eq lc($value) } @{ $self->see_also }) {
my $privs;
my $can = $self->check_can_change_field('see_also', '', $value, \$privs);
diff --git a/Bugzilla/BugUrl/JIRA.pm b/Bugzilla/BugUrl/JIRA.pm
index 97014e8a2..d0adcfed8 100644
--- a/Bugzilla/BugUrl/JIRA.pm
+++ b/Bugzilla/BugUrl/JIRA.pm
@@ -31,7 +31,7 @@ use Bugzilla::Util;
sub should_handle {
my ($class, $uri) = @_;
- return ($uri->path =~ m|/browse/[A-Z]+-\d+$|) ? 1 : 0;
+ return ($uri->path =~ m|/browse/[A-Z][A-Z]+-\d+$|) ? 1 : 0;
}
sub _check_value {
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 622facdc4..a89be351c 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -3485,6 +3485,37 @@ sub _fix_series_indexes {
return if $dbh->bz_index_info('series', 'series_category_idx');
$dbh->bz_drop_index('series', 'series_creator_idx');
+
+ # Fix duplicated names under the same category/subcategory before
+ # adding the more restrictive index.
+ my $duplicated_series = $dbh->selectall_arrayref(
+ 'SELECT s1.series_id, s1.category, s1.subcategory, s1.name
+ FROM series AS s1
+ INNER JOIN series AS s2
+ ON s1.category = s2.category
+ AND s1.subcategory = s2.subcategory
+ AND s1.name = s2.name
+ WHERE s1.series_id != s2.series_id');
+ my $sth_series_update = $dbh->prepare('UPDATE series SET name = ? WHERE series_id = ?');
+ my $sth_series_query = $dbh->prepare('SELECT 1 FROM series WHERE name = ?
+ AND category = ? AND subcategory = ?');
+
+ my %renamed_series;
+ foreach my $series (@$duplicated_series) {
+ my ($series_id, $category, $subcategory, $name) = @$series;
+ # Leave the first series alone, then rename duplicated ones.
+ if ($renamed_series{"${category}_${subcategory}_${name}"}++) {
+ print "Renaming series ${category}/${subcategory}/${name}...\n";
+ my $c = 0;
+ my $exists = 1;
+ while ($exists) {
+ $sth_series_query->execute($name . ++$c, $category, $subcategory);
+ $exists = $sth_series_query->fetchrow_array;
+ }
+ $sth_series_update->execute($name . $c, $series_id);
+ }
+ }
+
$dbh->bz_add_index('series', 'series_creator_idx', ['creator']);
$dbh->bz_add_index('series', 'series_category_idx',
{FIELDS => [qw(category subcategory name)], TYPE => 'UNIQUE'});