diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm index 9c1a839a3..a9d22fbc0 100644 --- a/Bugzilla/Error.pm +++ b/Bugzilla/Error.pm @@ -102,7 +102,8 @@ sub _throw_error # If we are within an eval(), do not do anything more # as we are eval'uating some test on purpose. - if ($mode == ERROR_MODE_DIE || _in_eval()) + if ($mode == ERROR_MODE_DIE || + $mode != ERROR_MODE_DIE_SOAP_FAULT && $mode != ERROR_MODE_JSON_RPC && _in_eval()) { die bless { message => ($msg ||= _error_message($type, $error, $vars)), type => $type, error => $error, vars => $vars }; } @@ -177,7 +178,7 @@ sub _throw_error $code = ERROR_UNKNOWN_TRANSIENT if $type eq 'user'; } if ($mode == ERROR_MODE_DIE_SOAP_FAULT) { - die bless { message => SOAP::Fault->faultcode($code)->faultstring($message) }; + die SOAP::Fault->faultcode($code)->faultstring($message); } else { my $server = Bugzilla->_json_server; @@ -193,7 +194,7 @@ sub _throw_error # we die with no message. JSON::RPC checks raise_error before # it checks $@, so it returns the proper error. die if _in_eval(); - #$server->response($server->error_response_header); # FIXME VERY UGLY HACK + $server->response($server->error_response_header); } } elsif ($mode == ERROR_MODE_AJAX) diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index a249de05d..5fbcf3314 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -95,7 +95,7 @@ sub fields { foreach my $field (@fields) { my $visibility_field = $field->visibility_field ? $field->visibility_field->name : undef; - my $vis_value = $field->visibility_value; + my $vis_values = $field->visibility_values; my $value_field = $field->value_field ? $field->value_field->name : undef; @@ -119,10 +119,7 @@ sub fields { display_name => $self->type('string', $field->description), is_on_bug_entry => $self->type('boolean', $field->enter_bug), visibility_field => $self->type('string', $visibility_field), - visibility_values => [ - defined $vis_value ? $self->type('string', $vis_value->name) - : () - ], + visibility_values => [ map { $self->type('string', $_->name) } @{ $vis_values || [] } ], ); if ($has_values) { $field_data{value_field} = $self->type('string', $value_field); @@ -197,14 +194,11 @@ sub _legal_field_values { else { my @values = Bugzilla::Field::Choice->type($field)->get_all(); foreach my $value (@values) { - my $vis_val = $value->visibility_value; + my $vis_values = $value->visibility_values; push(@result, { name => $self->type('string', $value->name), sortkey => $self->type('int' , $value->sortkey), - visibility_values => [ - defined $vis_val ? $self->type('string', $vis_val->name) - : () - ], + visibility_values => [ map { $self->type('string', $_->name) } @{ $vis_values || [] } ], }); } } diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm index 3ec64c6bc..346a5931c 100644 --- a/Bugzilla/WebService/Server/JSONRPC.pm +++ b/Bugzilla/WebService/Server/JSONRPC.pm @@ -42,10 +42,14 @@ sub create_json_coder { my $json = $self->SUPER::create_json_coder(@_); $json->allow_blessed(1); $json->convert_blessed(1); - # This may seem a little backwards, but what this really means is - # "don't convert our utf8 into byte strings, just leave it as a - # utf8 string." - $json->utf8(0) if Bugzilla->params->{'utf8'}; + #*********************************************************************# + # Оригинальное решение, но приводит к ошибкам # + # JSON::RPC::Server at line 170 (HTTP::Message content must be bytes) # + ## This may seem a little backwards, but what this really means is # + ## "don't convert our utf8 into byte strings, just leave it as a # + ## utf8 string." # + #$json->utf8(0) if Bugzilla->params->{'utf8'}; # + #*********************************************************************# return $json; } diff --git a/jsonrpc.cgi b/jsonrpc.cgi index f6ff0b8d2..c0a5b0c1b 100755 --- a/jsonrpc.cgi +++ b/jsonrpc.cgi @@ -40,5 +40,4 @@ Bugzilla->error_mode(ERROR_MODE_JSON_RPC); local @INC = (bz_locations()->{extensionsdir}, @INC); my $server = new Bugzilla::WebService::Server::JSONRPC; -$Bugzilla::Error::IN_EVAL++; $server->dispatch(WS_DISPATCH)->handle(); diff --git a/qa/t/webservice_bug_fields.t b/qa/t/webservice_bug_fields.t index 53877e89b..44914d0b0 100644 --- a/qa/t/webservice_bug_fields.t +++ b/qa/t/webservice_bug_fields.t @@ -60,15 +60,15 @@ use constant GLOBAL_GENERAL_FIELDS => qw( work_time ); use constant STANDARD_SELECT_FIELDS => - qw(bug_severity bug_status op_sys priority rep_platform resolution); + qw(bug_severity bug_status priority resolution); -use constant ALL_SELECT_FIELDS => (STANDARD_SELECT_FIELDS, - qw(cf_qa_status cf_single_select)); +use constant ALL_SELECT_FIELDS => (STANDARD_SELECT_FIELDS); +# qw(cf_qa_status cf_single_select)); use constant PRODUCT_FIELDS => qw(version target_milestone component); use constant ALL_FIELDS => (GLOBAL_GENERAL_FIELDS, ALL_SELECT_FIELDS, PRODUCT_FIELDS); -use constant PUBLIC_PRODUCT => 'Another Product'; +use constant PUBLIC_PRODUCT => 'PublicProduct'; use constant PRIVATE_PRODUCT => 'QA-Selenium-TEST'; sub get_field {