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
8a39b183
Commit
8a39b183
authored
Oct 01, 2013
by
Dave Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 919852 - Add ability to perform quicksearch using Bug.search
r/a=glob
parent
6d7c379c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
36 deletions
+52
-36
Quicksearch.pm
Bugzilla/Search/Quicksearch.pm
+4
-3
Bug.pm
Bugzilla/WebService/Bug.pm
+48
-33
No files found.
Bugzilla/Search/Quicksearch.pm
View file @
8a39b183
...
@@ -290,7 +290,7 @@ sub _bug_numbers_only {
...
@@ -290,7 +290,7 @@ sub _bug_numbers_only {
# Allow separation by comma or whitespace.
# Allow separation by comma or whitespace.
$searchstring
=~
s/[,\s]+/,/g
;
$searchstring
=~
s/[,\s]+/,/g
;
if
(
$searchstring
!~
/,/
)
{
if
(
$searchstring
!~
/,/
&&
!
i_am_webservice
()
)
{
# Single bug number; shortcut to show_bug.cgi.
# Single bug number; shortcut to show_bug.cgi.
print
$cgi
->
redirect
(
print
$cgi
->
redirect
(
-
uri
=>
correct_urlbase
()
.
"show_bug.cgi?id=$searchstring"
);
-
uri
=>
correct_urlbase
()
.
"show_bug.cgi?id=$searchstring"
);
...
@@ -311,8 +311,9 @@ sub _handle_alias {
...
@@ -311,8 +311,9 @@ sub _handle_alias {
# We use this direct SQL because we want quicksearch to be VERY fast.
# We use this direct SQL because we want quicksearch to be VERY fast.
my
$bug_id
=
Bugzilla
->
dbh
->
selectrow_array
(
my
$bug_id
=
Bugzilla
->
dbh
->
selectrow_array
(
q{SELECT bug_id FROM bugs WHERE alias = ?}
,
undef
,
$alias
);
q{SELECT bug_id FROM bugs WHERE alias = ?}
,
undef
,
$alias
);
# If the user cannot see the bug, do not resolve its alias.
# If the user cannot see the bug or if we are using a webservice,
if
(
$bug_id
&&
Bugzilla
->
user
->
can_see_bug
(
$bug_id
))
{
# do not resolve its alias.
if
(
$bug_id
&&
Bugzilla
->
user
->
can_see_bug
(
$bug_id
)
&&
!
i_am_webservice
())
{
$alias
=
url_quote
(
$alias
);
$alias
=
url_quote
(
$alias
);
print
Bugzilla
->
cgi
->
redirect
(
print
Bugzilla
->
cgi
->
redirect
(
-
uri
=>
correct_urlbase
()
.
"show_bug.cgi?id=$alias"
);
-
uri
=>
correct_urlbase
()
.
"show_bug.cgi?id=$alias"
);
...
...
Bugzilla/WebService/Bug.pm
View file @
8a39b183
...
@@ -26,9 +26,11 @@ use Bugzilla::Milestone;
...
@@ -26,9 +26,11 @@ use Bugzilla::Milestone;
use
Bugzilla::
Status
;
use
Bugzilla::
Status
;
use
Bugzilla::
Token
qw(issue_hash_token)
;
use
Bugzilla::
Token
qw(issue_hash_token)
;
use
Bugzilla::
Search
;
use
Bugzilla::
Search
;
use
Bugzilla::Search::
Quicksearch
;
use
List::
Util
qw(max)
;
use
List::
Util
qw(max)
;
use
List::
MoreUtils
qw(uniq)
;
use
List::
MoreUtils
qw(uniq)
;
use
Storable
qw(dclone)
;
#############
#############
# Constants #
# Constants #
...
@@ -447,79 +449,86 @@ sub search {
...
@@ -447,79 +449,86 @@ sub search {
Bugzilla
->
switch_to_shadow_db
();
Bugzilla
->
switch_to_shadow_db
();
if
(
defined
(
$params
->
{
offset
})
and
!
defined
(
$params
->
{
limit
})
)
{
my
$match_params
=
dclone
(
$params
);
delete
$match_params
->
{
include_fields
};
delete
$match_params
->
{
exclude_fields
};
# Determine whether this is a quicksearch query
if
(
exists
$match_params
->
{
quicksearch
})
{
my
$quicksearch
=
quicksearch
(
$match_params
->
{
'quicksearch'
});
my
$cgi
=
Bugzilla::
CGI
->
new
(
$quicksearch
);
$match_params
=
$cgi
->
Vars
;
}
if
(
defined
(
$match_params
->
{
offset
})
and
!
defined
(
$match_params
->
{
limit
})
)
{
ThrowCodeError
(
'param_required'
,
ThrowCodeError
(
'param_required'
,
{
param
=>
'limit'
,
function
=>
'Bug.search()'
});
{
param
=>
'limit'
,
function
=>
'Bug.search()'
});
}
}
my
$max_results
=
Bugzilla
->
params
->
{
max_search_results
};
my
$max_results
=
Bugzilla
->
params
->
{
max_search_results
};
unless
(
defined
$
params
->
{
limit
}
&&
$
params
->
{
limit
}
==
0
)
{
unless
(
defined
$
match_params
->
{
limit
}
&&
$match_
params
->
{
limit
}
==
0
)
{
if
(
!
defined
$
params
->
{
limit
}
||
$
params
->
{
limit
}
>
$max_results
)
{
if
(
!
defined
$
match_params
->
{
limit
}
||
$match_
params
->
{
limit
}
>
$max_results
)
{
$params
->
{
limit
}
=
$max_results
;
$
match_
params
->
{
limit
}
=
$max_results
;
}
}
}
}
else
{
else
{
delete
$params
->
{
limit
};
delete
$
match_
params
->
{
limit
};
delete
$params
->
{
offset
};
delete
$
match_
params
->
{
offset
};
}
}
$
params
=
Bugzilla::Bug::
map_fields
(
$
params
);
$
match_params
=
Bugzilla::Bug::
map_fields
(
$match_
params
);
my
%
options
=
(
fields
=>
[
'bug_id'
]
);
my
%
options
=
(
fields
=>
[
'bug_id'
]
);
# Find the highest custom field id
# Find the highest custom field id
my
@field_ids
=
grep
(
/^f(\d+)$/
,
keys
%
$params
);
my
@field_ids
=
grep
(
/^f(\d+)$/
,
keys
%
$
match_
params
);
my
$last_field_id
=
@field_ids
?
max
@field_ids
+
1
:
1
;
my
$last_field_id
=
@field_ids
?
max
@field_ids
+
1
:
1
;
# Do special search types for certain fields.
# Do special search types for certain fields.
if
(
my
$change_when
=
delete
$params
->
{
'delta_ts'
})
{
if
(
my
$change_when
=
delete
$
match_
params
->
{
'delta_ts'
})
{
$params
->
{
"f${last_field_id}"
}
=
'delta_ts'
;
$
match_
params
->
{
"f${last_field_id}"
}
=
'delta_ts'
;
$params
->
{
"o${last_field_id}"
}
=
'greaterthaneq'
;
$
match_
params
->
{
"o${last_field_id}"
}
=
'greaterthaneq'
;
$params
->
{
"v${last_field_id}"
}
=
$change_when
;
$
match_
params
->
{
"v${last_field_id}"
}
=
$change_when
;
$last_field_id
++
;
$last_field_id
++
;
}
}
if
(
my
$creation_when
=
delete
$params
->
{
'creation_ts'
})
{
if
(
my
$creation_when
=
delete
$
match_
params
->
{
'creation_ts'
})
{
$params
->
{
"f${last_field_id}"
}
=
'creation_ts'
;
$
match_
params
->
{
"f${last_field_id}"
}
=
'creation_ts'
;
$params
->
{
"o${last_field_id}"
}
=
'greaterthaneq'
;
$
match_
params
->
{
"o${last_field_id}"
}
=
'greaterthaneq'
;
$params
->
{
"v${last_field_id}"
}
=
$creation_when
;
$
match_
params
->
{
"v${last_field_id}"
}
=
$creation_when
;
$last_field_id
++
;
$last_field_id
++
;
}
}
# Some fields require a search type such as short desc, keywords, etc.
# Some fields require a search type such as short desc, keywords, etc.
foreach
my
$param
(
qw(short_desc longdesc status_whiteboard bug_file_loc)
)
{
foreach
my
$param
(
qw(short_desc longdesc status_whiteboard bug_file_loc)
)
{
if
(
defined
$
params
->
{
$param
}
&&
!
defined
$
params
->
{
$param
.
'_type'
})
{
if
(
defined
$
match_params
->
{
$param
}
&&
!
defined
$match_
params
->
{
$param
.
'_type'
})
{
$params
->
{
$param
.
'_type'
}
=
'allwordssubstr'
;
$
match_
params
->
{
$param
.
'_type'
}
=
'allwordssubstr'
;
}
}
}
}
if
(
defined
$
params
->
{
'keywords'
}
&&
!
defined
$
params
->
{
'keywords_type'
})
{
if
(
defined
$
match_params
->
{
'keywords'
}
&&
!
defined
$match_
params
->
{
'keywords_type'
})
{
$params
->
{
'keywords_type'
}
=
'allwords'
;
$
match_
params
->
{
'keywords_type'
}
=
'allwords'
;
}
}
# Backwards compatibility with old method regarding role search
# Backwards compatibility with old method regarding role search
$
params
->
{
'reporter'
}
=
delete
$params
->
{
'creator'
}
if
$
params
->
{
'creator'
};
$
match_params
->
{
'reporter'
}
=
delete
$match_params
->
{
'creator'
}
if
$match_
params
->
{
'creator'
};
foreach
my
$role
(
qw(assigned_to reporter qa_contact longdesc cc)
)
{
foreach
my
$role
(
qw(assigned_to reporter qa_contact longdesc cc)
)
{
next
if
!
exists
$params
->
{
$role
};
next
if
!
exists
$
match_
params
->
{
$role
};
my
$value
=
delete
$params
->
{
$role
};
my
$value
=
delete
$
match_
params
->
{
$role
};
$params
->
{
"f${last_field_id}"
}
=
$role
;
$
match_
params
->
{
"f${last_field_id}"
}
=
$role
;
$params
->
{
"o${last_field_id}"
}
=
"anywordssubstr"
;
$
match_
params
->
{
"o${last_field_id}"
}
=
"anywordssubstr"
;
$params
->
{
"v${last_field_id}"
}
=
ref
$value
?
join
(
" "
,
@
{
$value
})
:
$value
;
$
match_
params
->
{
"v${last_field_id}"
}
=
ref
$value
?
join
(
" "
,
@
{
$value
})
:
$value
;
$last_field_id
++
;
$last_field_id
++
;
}
}
my
%
match_params
=
%
{
$params
};
delete
$match_params
{
include_fields
};
delete
$match_params
{
exclude_fields
};
# If no other parameters have been passed other than limit and offset
# If no other parameters have been passed other than limit and offset
# then we throw error if system is configured to do so.
# then we throw error if system is configured to do so.
if
(
!
grep
(
!
/^(limit|offset)$/
,
keys
%
match_params
)
if
(
!
grep
(
!
/^(limit|offset)$/
,
keys
%
$
match_params
)
&&
!
Bugzilla
->
params
->
{
search_allow_no_criteria
})
&&
!
Bugzilla
->
params
->
{
search_allow_no_criteria
})
{
{
ThrowUserError
(
'buglist_parameters_required'
);
ThrowUserError
(
'buglist_parameters_required'
);
}
}
$options
{
order
}
=
[
split
(
/\s*,\s*/
,
delete
$match_params
{
order
})
]
if
$match_params
{
order
};
$options
{
order
}
=
[
split
(
/\s*,\s*/
,
delete
$match_params
->
{
order
})
]
if
$match_params
->
{
order
};
$options
{
params
}
=
\%
match_params
;
$options
{
params
}
=
$
match_params
;
my
$search
=
new
Bugzilla::
Search
(
%
options
);
my
$search
=
new
Bugzilla::
Search
(
%
options
);
my
(
$data
)
=
$search
->
data
;
my
(
$data
)
=
$search
->
data
;
...
@@ -2665,6 +2674,10 @@ C<string> Search the "Status Whiteboard" field on bugs for a substring.
...
@@ -2665,6 +2674,10 @@ C<string> Search the "Status Whiteboard" field on bugs for a substring.
Works the same as the C<summary> field described above, but searches the
Works the same as the C<summary> field described above, but searches the
Status Whiteboard field.
Status Whiteboard field.
=item C<quicksearch>
C<string> Search for bugs using quicksearch syntax.
=back
=back
=item B<Returns>
=item B<Returns>
...
@@ -2709,6 +2722,8 @@ by system configuration.
...
@@ -2709,6 +2722,8 @@ by system configuration.
=item Updated to allow for full search capability similar to the Bugzilla UI
=item Updated to allow for full search capability similar to the Bugzilla UI
in Bugzilla B<5.0>.
in Bugzilla B<5.0>.
=item Updated to allow quicksearch capability in Bugzilla B<5.0>.
=back
=back
=back
=back
...
...
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