diff options
author | Frédéric Buclin <LpSolit@gmail.com> | 2011-01-30 20:05:40 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2011-01-30 20:05:40 +0100 |
commit | cdc776b3a6b049862da803a1f7044a5e02a18058 (patch) | |
tree | 0288bf238595f68f58e9f5b9e8d910420820bfdb /Bugzilla/Install | |
parent | 604ed5413092fdd82dea9c15b2925a61442f3ea1 (diff) | |
download | bugzilla-cdc776b3a6b049862da803a1f7044a5e02a18058.tar.gz bugzilla-cdc776b3a6b049862da803a1f7044a5e02a18058.tar.xz |
Another bustage fix for bug 616185: in some cases, the columnlist parameter was appended to the list of bugs
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 04afbdb60..f0b6403cf 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -3486,21 +3486,33 @@ sub _migrate_user_tags { # Tags are all lowercase. my $tag_name = lc($name); - $sth_tags->execute($user_id, $tag_name); + # Some queries were incorrectly parsed when _migrate_user_tags() + # was first implemented, and so some tags may have already been + # added to the DB. We don't want to crash in that case. + eval { $sth_tags->execute($user_id, $tag_name); }; my $tag_id = $dbh->selectrow_array( 'SELECT id FROM tags WHERE user_id = ? AND name = ?', undef, ($user_id, $tag_name)); - $query =~ s/^bug_id=//; - # Commas in Bugzilla 3.x are encoded as %2C, but not in 2.22. - $query =~ s/%2C/,/g; - my @bug_ids = split(/[\s,]+/, $query); - $sth_bug_tag->execute($_, $tag_id) foreach @bug_ids; - + my $columnlist = ""; + if ($query =~ /^bug_id=([^&;]+)(.*)$/) { + my $buglist = $1; + $columnlist = $2 if $2; + # Commas in Bugzilla 3.x are encoded as %2C, but not in 2.22. + $buglist =~ s/%2C/,/g; + my @bug_ids = split(/[\s,]+/, $buglist); + foreach my $bug_id (@bug_ids) { + # Some sanity check. We never know. + next unless detaint_natural($bug_id); + # For the same reason as above, let's do it in an eval. + eval { $sth_bug_tag->execute($bug_id, $tag_id); }; + } + } + # Existing tags may be used in whines, or shared with # other users. So we convert them rather than delete them. my $encoded_name = url_quote($tag_name); - $sth_nq->execute("tag=$encoded_name", $user_id, $name); + $sth_nq->execute("tag=$encoded_name$columnlist", $user_id, $name); } $dbh->bz_drop_column('namedqueries', 'query_type'); |