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
79542d43
Commit
79542d43
authored
Jun 13, 2011
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 660866: Allow editing of old "boolean chart" searches using the new
"custom search" UI controls on the advanced search form. r=mkanat, a=mkanat (module owner)
parent
b394ae8a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
19 deletions
+73
-19
Search.pm
Bugzilla/Search.pm
+32
-7
Clause.pm
Bugzilla/Search/Clause.pm
+24
-10
Condition.pm
Bugzilla/Search/Condition.pm
+7
-2
query.cgi
query.cgi
+10
-0
No files found.
Bugzilla/Search.pm
View file @
79542d43
...
...
@@ -719,6 +719,25 @@ sub search_description {
return
$self
->
{
'search_description'
};
}
sub
boolean_charts_to_custom_search
{
my
(
$self
,
$cgi_buffer
)
=
@_
;
my
@as_params
=
$self
->
_boolean_charts
->
as_params
;
# We need to start our new ids after the last custom search "f" id.
# We can just pick the last id in the array because they are sorted
# numerically.
my
$last_id
=
(
$self
->
_field_ids
)[
-
1
];
my
$count
=
defined
(
$last_id
)
?
$last_id
+
1
:
0
;
foreach
my
$param_set
(
@as_params
)
{
foreach
my
$name
(
keys
%
$param_set
)
{
my
$value
=
$param_set
->
{
$name
};
next
if
!
defined
$value
;
$cgi_buffer
->
param
(
$name
.
$count
,
$value
);
}
$count
++
;
}
}
######################
# Internal Accessors #
######################
...
...
@@ -1542,15 +1561,10 @@ sub _boolean_charts {
sub
_custom_search
{
my
(
$self
)
=
@_
;
my
$params
=
$self
->
_params
;
my
@param_list
=
keys
%
$params
;
my
@field_params
=
grep
{
/^f\d+$/
}
@param_list
;
my
@field_ids
=
map
{
/(\d+)/
;
$1
}
@field_params
;
@field_ids
=
sort
{
$a
<=>
$b
}
@field_ids
;
my
$current_clause
=
new
Bugzilla::Search::
Clause
(
$params
->
{
j_top
});
my
@clause_stack
;
foreach
my
$id
(
@
field_ids
)
{
foreach
my
$id
(
$self
->
_
field_ids
)
{
my
$field
=
$params
->
{
"f$id"
};
if
(
$field
eq
'OP'
)
{
my
$joiner
=
$params
->
{
"j$id"
};
...
...
@@ -1581,6 +1595,17 @@ sub _custom_search {
return
$clause_stack
[
0
]
||
$current_clause
;
}
sub
_field_ids
{
my
(
$self
)
=
@_
;
my
$params
=
$self
->
_params
;
my
@param_list
=
keys
%
$params
;
my
@field_params
=
grep
{
/^f\d+$/
}
@param_list
;
my
@field_ids
=
map
{
/(\d+)/
;
$1
}
@field_params
;
@field_ids
=
sort
{
$a
<=>
$b
}
@field_ids
;
return
@field_ids
;
}
sub
_handle_chart
{
my
(
$self
,
$chart_id
,
$condition
)
=
@_
;
my
$dbh
=
Bugzilla
->
dbh
;
...
...
Bugzilla/Search/Clause.pm
View file @
79542d43
...
...
@@ -44,19 +44,14 @@ sub children {
sub
joiner
{
return
$_
[
0
]
->
{
joiner
}
}
sub
has_children
{
my
(
$self
)
=
@_
;
return
scalar
(
@
{
$self
->
children
})
>
0
?
1
:
0
;
}
sub
has_valid_conditions
{
sub
has_translated_conditions
{
my
(
$self
)
=
@_
;
my
$children
=
$self
->
children
;
return
1
if
grep
{
$_
->
isa
(
'Bugzilla::Search::Condition'
)
&&
$_
->
translated
}
@$children
;
foreach
my
$child
(
@$children
)
{
next
if
$child
->
isa
(
'Bugzilla::Search::Condition'
);
return
1
if
$child
->
has_
vali
d_conditions
;
return
1
if
$child
->
has_
translate
d_conditions
;
}
return
0
;
}
...
...
@@ -100,7 +95,7 @@ sub as_string {
my
(
$self
)
=
@_
;
my
@strings
;
foreach
my
$child
(
@
{
$self
->
children
})
{
next
if
$child
->
isa
(
__PACKAGE__
)
&&
!
$child
->
has_
vali
d_conditions
;
next
if
$child
->
isa
(
__PACKAGE__
)
&&
!
$child
->
has_
translate
d_conditions
;
next
if
$child
->
isa
(
'Bugzilla::Search::Condition'
)
&&
!
$child
->
translated
;
...
...
@@ -119,5 +114,25 @@ sub as_string {
return
$sql
;
}
# Search.pm converts URL parameters to Clause objects. This helps do the
# reverse.
sub
as_params
{
my
(
$self
)
=
@_
;
my
@params
;
foreach
my
$child
(
@
{
$self
->
children
})
{
if
(
$child
->
isa
(
__PACKAGE__
))
{
my
%
open_paren
=
(
f
=>
'OP'
,
n
=>
scalar
$child
->
negate
,
j
=>
$child
->
joiner
);
push
(
@params
,
\%
open_paren
);
push
(
@params
,
$child
->
as_params
);
my
%
close_paren
=
(
f
=>
'CP'
);
push
(
@params
,
\%
close_paren
);
}
else
{
push
(
@params
,
$child
->
as_params
);
}
}
return
@params
;
}
1
;
\ No newline at end of file
1
;
Bugzilla/Search/Condition.pm
View file @
79542d43
...
...
@@ -55,6 +55,12 @@ sub as_string {
return
$term
;
}
sub
as_params
{
my
(
$self
)
=
@_
;
return
{
f
=>
$self
->
field
,
o
=>
$self
->
operator
,
v
=>
$self
->
value
,
n
=>
scalar
$self
->
negate
};
}
sub
negate
{
my
(
$self
,
$value
)
=
@_
;
if
(
@_
==
2
)
{
...
...
@@ -73,4 +79,4 @@ sub condition {
value
=>
$value
});
}
1
;
\ No newline at end of file
1
;
query.cgi
View file @
79542d43
...
...
@@ -80,6 +80,16 @@ sub PrefillForm {
$buf
=
new
Bugzilla::
CGI
(
$buf
);
my
$foundone
=
0
;
# If there are old-style boolean charts in the URL (from an old saved
# search or from an old link on the web somewhere) then convert them
# to the new "custom search" format so that the form is populated
# properly.
my
$any_boolean_charts
=
grep
{
/^field-?\d+/
}
$buf
->
param
();
if
(
$any_boolean_charts
)
{
my
$search
=
new
Bugzilla::
Search
(
params
=>
scalar
$buf
->
Vars
);
$search
->
boolean_charts_to_custom_search
(
$buf
);
}
# Query parameters that don't represent form fields on this page.
my
@skip
=
qw(format query_format list_id columnlist)
;
...
...
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