Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
dbaf1c3a
Commit
dbaf1c3a
authored
Jul 15, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 398308: Make Search.pm take a hashref for its "params" argument
instead of taking a CGI object. r=mkanat, a=mkanat (module owner)
parent
6a2a01fb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
101 additions
and
157 deletions
+101
-157
CGI.pm
Bugzilla/CGI.pm
+0
-12
Search.pm
Bugzilla/Search.pm
+78
-56
buglist.cgi
buglist.cgi
+1
-1
collectstats.pl
collectstats.pl
+1
-1
report.cgi
report.cgi
+1
-1
whine.pl
whine.pl
+1
-1
AndTest.pm
xt/lib/Bugzilla/Test/Search/AndTest.pm
+6
-6
FakeCGI.pm
xt/lib/Bugzilla/Test/Search/FakeCGI.pm
+0
-62
FieldTest.pm
xt/lib/Bugzilla/Test/Search/FieldTest.pm
+7
-11
OrTest.pm
xt/lib/Bugzilla/Test/Search/OrTest.pm
+6
-6
No files found.
Bugzilla/CGI.pm
View file @
dbaf1c3a
...
@@ -110,7 +110,6 @@ sub new {
...
@@ -110,7 +110,6 @@ sub new {
sub
canonicalise_query
{
sub
canonicalise_query
{
my
(
$self
,
@exclude
)
=
@_
;
my
(
$self
,
@exclude
)
=
@_
;
$self
->
convert_old_params
();
# Reconstruct the URL by concatenating the sorted param=value pairs
# Reconstruct the URL by concatenating the sorted param=value pairs
my
@parameters
;
my
@parameters
;
foreach
my
$key
(
sort
(
$self
->
param
()))
{
foreach
my
$key
(
sort
(
$self
->
param
()))
{
...
@@ -135,17 +134,6 @@ sub canonicalise_query {
...
@@ -135,17 +134,6 @@ sub canonicalise_query {
return
join
(
"&"
,
@parameters
);
return
join
(
"&"
,
@parameters
);
}
}
sub
convert_old_params
{
my
$self
=
shift
;
# bugidtype is now bug_id_type.
if
(
$self
->
param
(
'bugidtype'
))
{
my
$value
=
$self
->
param
(
'bugidtype'
)
eq
'exclude'
?
'nowords'
:
'anyexact'
;
$self
->
param
(
'bug_id_type'
,
$value
);
$self
->
delete
(
'bugidtype'
);
}
}
sub
clean_search_url
{
sub
clean_search_url
{
my
$self
=
shift
;
my
$self
=
shift
;
# Delete any empty URL parameter.
# Delete any empty URL parameter.
...
...
Bugzilla/Search.pm
View file @
dbaf1c3a
This diff is collapsed.
Click to expand it.
buglist.cgi
View file @
dbaf1c3a
...
@@ -849,7 +849,7 @@ my @orderstrings = split(/,\s*/, $order);
...
@@ -849,7 +849,7 @@ my @orderstrings = split(/,\s*/, $order);
# Generate the basic SQL query that will be used to generate the bug list.
# Generate the basic SQL query that will be used to generate the bug list.
my
$search
=
new
Bugzilla::
Search
(
'fields'
=>
\
@selectcolumns
,
my
$search
=
new
Bugzilla::
Search
(
'fields'
=>
\
@selectcolumns
,
'params'
=>
$param
s
,
'params'
=>
scalar
$params
->
Var
s
,
'order'
=>
\
@orderstrings
);
'order'
=>
\
@orderstrings
);
my
$query
=
$search
->
sql
;
my
$query
=
$search
->
sql
;
$vars
->
{
'search_description'
}
=
$search
->
search_description
;
$vars
->
{
'search_description'
}
=
$search
->
search_description
;
...
...
collectstats.pl
View file @
dbaf1c3a
...
@@ -509,7 +509,7 @@ sub CollectSeriesData {
...
@@ -509,7 +509,7 @@ sub CollectSeriesData {
# Do not die if Search->new() detects invalid data, such as an obsolete
# Do not die if Search->new() detects invalid data, such as an obsolete
# login name or a renamed product or component, etc.
# login name or a renamed product or component, etc.
eval
{
eval
{
my
$search
=
new
Bugzilla::
Search
(
'params'
=>
$cgi
,
my
$search
=
new
Bugzilla::
Search
(
'params'
=>
scalar
$cgi
->
Vars
,
'fields'
=>
[
"bug_id"
],
'fields'
=>
[
"bug_id"
],
'user'
=>
$user
);
'user'
=>
$user
);
my
$sql
=
$search
->
sql
;
my
$sql
=
$search
->
sql
;
...
...
report.cgi
View file @
dbaf1c3a
...
@@ -127,7 +127,7 @@ my @axis_fields = ($row_field || EMPTY_COLUMN,
...
@@ -127,7 +127,7 @@ my @axis_fields = ($row_field || EMPTY_COLUMN,
# Clone the params, so that Bugzilla::Search can modify them
# Clone the params, so that Bugzilla::Search can modify them
my
$params
=
new
Bugzilla::
CGI
(
$cgi
);
my
$params
=
new
Bugzilla::
CGI
(
$cgi
);
my
$search
=
new
Bugzilla::
Search
(
'fields'
=>
\
@axis_fields
,
my
$search
=
new
Bugzilla::
Search
(
'fields'
=>
\
@axis_fields
,
'params'
=>
$param
s
);
'params'
=>
scalar
$params
->
Var
s
);
my
$query
=
$search
->
sql
;
my
$query
=
$search
->
sql
;
$::SIG
{
TERM
}
=
'DEFAULT'
;
$::SIG
{
TERM
}
=
'DEFAULT'
;
...
...
whine.pl
View file @
dbaf1c3a
...
@@ -446,7 +446,7 @@ sub run_queries {
...
@@ -446,7 +446,7 @@ sub run_queries {
my
$searchparams
=
new
Bugzilla::
CGI
(
$savedquery
);
my
$searchparams
=
new
Bugzilla::
CGI
(
$savedquery
);
my
$search
=
new
Bugzilla::
Search
(
my
$search
=
new
Bugzilla::
Search
(
'fields'
=>
\
@searchfields
,
'fields'
=>
\
@searchfields
,
'params'
=>
$searchparam
s
,
'params'
=>
scalar
$searchparams
->
Var
s
,
'user'
=>
$args
->
{
'recipient'
},
# the search runs as the recipient
'user'
=>
$args
->
{
'recipient'
},
# the search runs as the recipient
);
);
my
$sqlquery
=
$search
->
sql
;
my
$sqlquery
=
$search
->
sql
;
...
...
xt/lib/Bugzilla/Test/Search/AndTest.pm
View file @
dbaf1c3a
...
@@ -25,7 +25,6 @@ package Bugzilla::Test::Search::AndTest;
...
@@ -25,7 +25,6 @@ package Bugzilla::Test::Search::AndTest;
use
base
qw(Bugzilla::Test::Search::OrTest)
;
use
base
qw(Bugzilla::Test::Search::OrTest)
;
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
FakeCGI
;
use
List::
MoreUtils
qw(all)
;
use
List::
MoreUtils
qw(all)
;
use
constant
type
=>
'AND'
;
use
constant
type
=>
'AND'
;
...
@@ -55,15 +54,15 @@ sub _join_broken_constant { {} }
...
@@ -55,15 +54,15 @@ sub _join_broken_constant { {} }
sub
search_params
{
sub
search_params
{
my
(
$self
)
=
@_
;
my
(
$self
)
=
@_
;
my
@all_params
=
map
{
$_
->
search_params
}
$self
->
field_tests
;
my
@all_params
=
map
{
$_
->
search_params
}
$self
->
field_tests
;
my
$params
=
new
Bugzilla::Test::Search::
FakeCGI
;
my
%
params
;
my
$chart
=
0
;
my
$chart
=
0
;
foreach
my
$item
(
@all_params
)
{
foreach
my
$item
(
@all_params
)
{
$params
->
param
(
"field0-$chart-0"
,
$item
->
param
(
'field0-0-0'
))
;
$params
{
"field0-$chart-0"
}
=
$item
->
{
'field0-0-0'
}
;
$params
->
param
(
"type0-$chart-0"
,
$item
->
param
(
'type0-0-0'
))
;
$params
{
"type0-$chart-0"
}
=
$item
->
{
'type0-0-0'
}
;
$params
->
param
(
"value0-$chart-0"
,
$item
->
param
(
'value0-0-0'
))
;
$params
{
"value0-$chart-0"
}
=
$item
->
{
'value0-0-0'
}
;
$chart
++
;
$chart
++
;
}
}
return
$
params
;
return
\%
params
;
}
}
1
;
1
;
\ No newline at end of file
xt/lib/Bugzilla/Test/Search/FakeCGI.pm
deleted
100644 → 0
View file @
6a2a01fb
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Everything Solved, Inc.
# Portions created by the Initial Developer are Copyright (C) 2010 the
# Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Max Kanat-Alexander <mkanat@bugzilla.org>
# Calling CGI::param over and over turned out to be one of the slowest
# parts of search.t. So we create a simpler thing here that just supports
# "param" in a fast way.
package
Bugzilla::Test::Search::
FakeCGI
;
sub
new
{
my
(
$class
)
=
@_
;
return
bless
{},
$class
;
}
sub
param
{
my
(
$self
,
$name
,
@values
)
=
@_
;
if
(
!
defined
$name
)
{
return
keys
%
$self
;
}
if
(
@values
)
{
if
(
ref
$values
[
0
]
eq
'ARRAY'
)
{
$self
->
{
$name
}
=
$values
[
0
];
}
else
{
$self
->
{
$name
}
=
\
@values
;
}
}
return
()
if
!
exists
$self
->
{
$name
};
my
$item
=
$self
->
{
$name
};
return
wantarray
?
@
{
$item
||
[]
}
:
$item
->
[
0
];
}
sub
delete
{
my
(
$self
,
$name
)
=
@_
;
delete
$self
->
{
$name
};
}
# We don't need to do this, because we don't use old params in search.t.
sub
convert_old_params
{}
1
;
\ No newline at end of file
xt/lib/Bugzilla/Test/Search/FieldTest.pm
View file @
dbaf1c3a
...
@@ -26,7 +26,6 @@ package Bugzilla::Test::Search::FieldTest;
...
@@ -26,7 +26,6 @@ package Bugzilla::Test::Search::FieldTest;
use
strict
;
use
strict
;
use
warnings
;
use
warnings
;
use
Bugzilla::Test::Search::
FakeCGI
;
use
Bugzilla::
Search
;
use
Bugzilla::
Search
;
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
Constants
;
...
@@ -278,19 +277,16 @@ sub join_broken {
...
@@ -278,19 +277,16 @@ sub join_broken {
# The CGI object that will get passed to Bugzilla::Search as its arguments.
# The CGI object that will get passed to Bugzilla::Search as its arguments.
sub
search_params
{
sub
search_params
{
my
$self
=
shift
;
my
(
$self
)
=
@_
;
return
$self
->
{
search_params
}
if
$self
->
{
search_params
};
return
$self
->
{
search_params
}
if
$self
->
{
search_params
};
my
$field
=
$self
->
field
;
my
%
params
=
(
my
$operator
=
$self
->
operator
;
"field0-0-0"
=>
$self
->
field
,
my
$value
=
$self
->
translated_value
;
"type0-0-0"
=>
$self
->
operator
,
"value0-0-0"
=>
$self
->
translated_value
,
my
$cgi
=
new
Bugzilla::Test::Search::
FakeCGI
;
);
$cgi
->
param
(
"field0-0-0"
,
$field
);
$cgi
->
param
(
'type0-0-0'
,
$operator
);
$cgi
->
param
(
'value0-0-0'
,
$value
);
$self
->
{
search_params
}
=
$cgi
;
$self
->
{
search_params
}
=
\%
params
;
return
$self
->
{
search_params
};
return
$self
->
{
search_params
};
}
}
...
...
xt/lib/Bugzilla/Test/Search/OrTest.pm
View file @
dbaf1c3a
...
@@ -25,7 +25,6 @@ package Bugzilla::Test::Search::OrTest;
...
@@ -25,7 +25,6 @@ package Bugzilla::Test::Search::OrTest;
use
base
qw(Bugzilla::Test::Search::FieldTest)
;
use
base
qw(Bugzilla::Test::Search::FieldTest)
;
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
FakeCGI
;
use
List::
MoreUtils
qw(any uniq)
;
use
List::
MoreUtils
qw(any uniq)
;
use
constant
type
=>
'OR'
;
use
constant
type
=>
'OR'
;
...
@@ -172,15 +171,15 @@ sub search_columns {
...
@@ -172,15 +171,15 @@ sub search_columns {
sub
search_params
{
sub
search_params
{
my
(
$self
)
=
@_
;
my
(
$self
)
=
@_
;
my
@all_params
=
map
{
$_
->
search_params
}
$self
->
field_tests
;
my
@all_params
=
map
{
$_
->
search_params
}
$self
->
field_tests
;
my
$params
=
new
Bugzilla::Test::Search::
FakeCGI
;
my
%
params
;
my
$chart
=
0
;
my
$chart
=
0
;
foreach
my
$item
(
@all_params
)
{
foreach
my
$item
(
@all_params
)
{
$params
->
param
(
"field0-0-$chart"
,
$item
->
param
(
'field0-0-0'
))
;
$params
{
"field0-0-$chart"
}
=
$item
->
{
'field0-0-0'
}
;
$params
->
param
(
"type0-0-$chart"
,
$item
->
param
(
'type0-0-0'
))
;
$params
{
"type0-0-$chart"
}
=
$item
->
{
'type0-0-0'
}
;
$params
->
param
(
"value0-0-$chart"
,
$item
->
param
(
'value0-0-0'
))
;
$params
{
"value0-0-$chart"
}
=
$item
->
{
'value0-0-0'
}
;
$chart
++
;
$chart
++
;
}
}
return
$
params
;
return
\%
params
;
}
}
1
;
1
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment