From 5db6eeb9cf4bf82d785dd193703b46b2139247e5 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 21 Apr 2015 14:00:18 +0800 Subject: Bug 579089: Change default Hardware / OS values to be "Unspecified/Unspecified" --- Bugzilla/Bug.pm | 13 +++++++++---- Bugzilla/UserAgent.pm | 4 ++-- Bugzilla/WebService/Product.pm | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index e1f533274..6dbcffe34 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -702,10 +702,15 @@ sub create { unless defined $params->{bug_severity}; $params->{priority} = Bugzilla->params->{defaultpriority} unless defined $params->{priority}; - $params->{op_sys} = Bugzilla->params->{defaultopsys} - unless defined $params->{op_sys}; - $params->{rep_platform} = Bugzilla->params->{defaultplatform} - unless defined $params->{rep_platform}; + + # BMO - per-product hw/os defaults + if (!defined $params->{rep_platform} || !defined $params->{op_sys}) { + if (my $product = Bugzilla::Product->new({ name => $params->{product}, cache => 1 })) { + $params->{rep_platform} //= $product->default_product; + $params->{op_sys} //= $product->default_op_sys; + } + } + # Make sure a comment is always defined. $params->{comment} = '' unless defined $params->{comment}; diff --git a/Bugzilla/UserAgent.pm b/Bugzilla/UserAgent.pm index 62d6115a9..9c8686f0c 100644 --- a/Bugzilla/UserAgent.pm +++ b/Bugzilla/UserAgent.pm @@ -183,7 +183,7 @@ use constant OS_MAP => ( ); sub detect_platform { - my $userAgent = $ENV{'HTTP_USER_AGENT'} || ''; + my $userAgent = shift || Bugzilla->cgi->user_agent || ''; my @detected; my $iterator = natatime(2, PLATFORMS_MAP); while (my($re, $ra) = $iterator->()) { @@ -195,7 +195,7 @@ sub detect_platform { } sub detect_op_sys { - my $userAgent = $ENV{'HTTP_USER_AGENT'} || ''; + my $userAgent = shift || Bugzilla->cgi->user_agent || ''; my @detected; my $iterator = natatime(2, OS_MAP); while (my($re, $ra) = $iterator->()) { diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm index be082c778..b7484327f 100644 --- a/Bugzilla/WebService/Product.pm +++ b/Bugzilla/WebService/Product.pm @@ -202,6 +202,9 @@ sub _product_to_hash { $self->_milestone_to_hash($_, $params) } @{$product->milestones}]; } + # BMO - add default hw/os + $field_data->{default_platform} = $self->type('string', $product->default_platform); + $field_data->{default_op_sys} = $self->type('string', $product->default_op_sys); return filter($params, $field_data); } -- cgit v1.2.3-24-g4f1b