aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjocuri%softhome.net <>2004-12-31 16:01:17 +0000
committerjocuri%softhome.net <>2004-12-31 16:01:17 +0000
commitd08b4fc7d70e2e625212e6abeef66b76e81c8ff0 (patch)
treee2db4775cc4c449e8b43248bb8cdd161af67bc46
parentPatch for bug 275523: Replace INNER JOIN in flag searches with LEFT JOIN; pat... (diff)
downloadbugzilla-d08b4fc7d70e2e625212e6abeef66b76e81c8ff0.tar.gz
bugzilla-d08b4fc7d70e2e625212e6abeef66b76e81c8ff0.tar.bz2
bugzilla-d08b4fc7d70e2e625212e6abeef66b76e81c8ff0.zip
Patch for bug 275788: Provide a line of code that defines legal query formats for other scripts to use; patch by Colin S. Ogilvie <colin.ogilvie@gmail.com>, r=vladd, a=justdave.
-rw-r--r--Bugzilla/Search.pm12
-rwxr-xr-xquery.cgi3
-rwxr-xr-xuserprefs.cgi18
3 files changed, 26 insertions, 7 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 9570a709d..75307a0e3 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -32,6 +32,8 @@ use strict;
use vars qw($userid);
package Bugzilla::Search;
+use base qw(Exporter);
+@Bugzilla::Search::EXPORT = qw(IsValidQueryType);
use Bugzilla::Config;
use Bugzilla::Error;
@@ -1260,4 +1262,14 @@ sub getSQL {
return $self->{'sql'};
}
+# Define if the Query Type passed in is a valid query type that we can deal with
+sub IsValidQueryType
+{
+ my ($queryType) = @_;
+ if (grep { $_ eq $queryType } qw(specific advanced)) {
+ return 1;
+ }
+ return 0;
+}
+
1;
diff --git a/query.cgi b/query.cgi
index 628c731cc..4a305c190 100755
--- a/query.cgi
+++ b/query.cgi
@@ -30,6 +30,7 @@ use lib ".";
require "CGI.pl";
use Bugzilla::Constants;
+use Bugzilla::Search;
use vars qw(
@CheckOptionValues
@@ -423,7 +424,7 @@ if (!($cgi->param('query_format') || $cgi->param('format'))) {
# Set cookie to current format as default, but only if the format
# one that we should remember.
-if (grep { $_ eq $vars->{'format'} } qw(specific advanced)) {
+if (IsValidQueryType($vars->{'format'})) {
$cgi->send_cookie(-name => 'DEFAULTFORMAT',
-value => $vars->{'format'},
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
diff --git a/userprefs.cgi b/userprefs.cgi
index f8de9915d..323c87d53 100755
--- a/userprefs.cgi
+++ b/userprefs.cgi
@@ -27,6 +27,7 @@ use lib qw(.);
use Bugzilla;
use Bugzilla::Constants;
+use Bugzilla::Search;
require "CGI.pl";
@@ -304,13 +305,18 @@ sub DoSavedSearches() {
my @queries = @{Bugzilla->user->queries};
my @newqueries;
foreach my $q (@queries) {
- if ($q->{'query'} !~ /query_format=(advanced|specific)/) {
- if ($q->{'query'} =~ /query_format=&/) {
- $q->{'query'} =~ s/query_format=&/query_format=advanced&/;
- }
- else {
- $q->{'query'} .= '&query_format=advanced';
+ if ($q->{'query'} =~ /query_format=([^&]*)/) {
+ my $format = $1;
+ if (!IsValidQueryType($format)) {
+ if ($format eq "") {
+ $q->{'query'} =~ s/query_format=/query_format=advanced/;
+ }
+ else {
+ $q->{'query'} .= '&query_format=advanced';
+ }
}
+ } else {
+ $q->{'query'} .= '&query_format=advanced';
}
push @newqueries, $q;
}