summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2015-07-24 10:18:16 +0200
committerDavid Lawrence <dkl@mozilla.com>2015-07-24 10:18:16 +0200
commit92f16f758434dd1ce92a1043ade9bf7f8438fa78 (patch)
tree8651f11b381e3feda5b21adaa30d94b123c6eecb
parent50c7dab9e0f27b8f1214b12c4c51ad133329173f (diff)
downloadbugzilla-92f16f758434dd1ce92a1043ade9bf7f8438fa78.tar.gz
bugzilla-92f16f758434dd1ce92a1043ade9bf7f8438fa78.tar.xz
Bug 1184828: backport bug 1161070 to bmo (api searches should honour the same fields in its "order" parameter as the web UI)
-rw-r--r--Bugzilla/WebService/Bug.pm20
-rwxr-xr-xbuglist.cgi35
2 files changed, 31 insertions, 24 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index fa66edb80..d0fe8465f 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -611,7 +611,25 @@ sub search {
ThrowUserError('buglist_parameters_required');
}
- $options{order} = [ split(/\s*,\s*/, delete $match_params->{order}) ] if $match_params->{order};
+ # Allow the use of order shortcuts similar to web UI
+ if ($match_params->{order}) {
+ # Convert the value of the "order" form field into a list of columns
+ # by which to sort the results.
+ my %order_types = (
+ "Bug Number" => [ "bug_id" ],
+ "Importance" => [ "priority", "bug_severity" ],
+ "Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ],
+ "Last Changed" => [ "changeddate", "bug_status", "priority",
+ "assigned_to", "bug_id" ],
+ );
+ if ($order_types{$match_params->{order}}) {
+ $options{order} = $order_types{$match_params->{order}};
+ }
+ else {
+ $options{order} = [ split(/\s*,\s*/, $match_params->{order}) ];
+ }
+ }
+
$options{params} = $match_params;
my $search = new Bugzilla::Search(%options);
diff --git a/buglist.cgi b/buglist.cgi
index f2cc0a53c..055de388d 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -681,29 +681,18 @@ my @order_columns;
if ($order) {
# Convert the value of the "order" form field into a list of columns
# by which to sort the results.
- ORDER: for ($order) {
- /^Bug Number$/ && do {
- @order_columns = ("bug_id");
- last ORDER;
- };
- /^Importance$/ && do {
- @order_columns = ("priority", "bug_severity");
- last ORDER;
- };
- /^Assignee$/ && do {
- @order_columns = ("assigned_to", "bug_status", "priority",
- "bug_id");
- last ORDER;
- };
- /^Last Changed$/ && do {
- @order_columns = ("changeddate", "bug_status", "priority",
- "assigned_to", "bug_id");
- last ORDER;
- };
- do {
- # A custom list of columns. Bugzilla::Search will validate items.
- @order_columns = split(/\s*,\s*/, $order);
- };
+ my %order_types = (
+ "Bug Number" => [ "bug_id" ],
+ "Importance" => [ "priority", "bug_severity" ],
+ "Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ],
+ "Last Changed" => [ "changeddate", "bug_status", "priority",
+ "assigned_to", "bug_id" ],
+ );
+ if ($order_types{$order}) {
+ @order_columns = @{ $order_types{$order} };
+ }
+ else {
+ @order_columns = split(/\s*,\s*/, $order);
}
}