Created
October 7, 2016 20:02
-
-
Save dklawren/a62090758a93d92cf9efa64a227faaff to your computer and use it in GitHub Desktop.
1301884_dkl_fix.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Bugzilla/API/1_0/Util.pm b/Bugzilla/API/1_0/Util.pm | |
index a67db2d..e8756db 100644 | |
--- a/Bugzilla/API/1_0/Util.pm | |
+++ b/Bugzilla/API/1_0/Util.pm | |
@@ -361,10 +361,10 @@ sub datetime_format_outbound { | |
# simple types | |
-sub as_boolean { $_[0] ? JSON::true : JSON::false } | |
-sub as_double { defined $_[0] ? $_[0] + 0.0 : JSON::null } | |
-sub as_int { defined $_[0] ? int($_[0]) : JSON::null } | |
-sub as_string { defined $_[0] ? $_[0] . '' : JSON::null } | |
+sub as_boolean { $_[0] ? \1 : \0 } | |
+sub as_double { defined $_[0] ? $_[0] + 0.0 : undef } | |
+sub as_int { defined $_[0] ? int($_[0]) : undef } | |
+sub as_string { defined $_[0] ? $_[0] . '' : undef } | |
# array types | |
@@ -378,17 +378,17 @@ sub as_string_array { [ map { as_string($_) } @{ $_[0] // [] } ] } | |
sub as_datetime { | |
return defined $_[0] | |
? datetime_from($_[0], 'UTC')->iso8601() . 'Z' | |
- : JSON::null; | |
+ : undef; | |
} | |
sub as_login { | |
defined $_[0] | |
? ( Bugzilla->params->{use_email_as_login} ? email_filter($_[0]) : $_[0] . '' ) | |
- : JSON::null; | |
+ : undef; | |
} | |
sub as_email { | |
- defined($_[0]) && Bugzilla->user->in_group('editusers') ? $_[0] . '' : JSON::null; | |
+ defined($_[0]) && Bugzilla->user->in_group('editusers') ? $_[0] . '' : undef; | |
} | |
sub as_base64 { | |
@@ -486,29 +486,29 @@ Returns a base64 encoded value based on the parameter passed in. | |
=head2 as_boolean | |
-If a true value is passed as a parameter, the method will return a JSON::true. | |
-If not returns JSON::false. | |
+If a true value is passed as a parameter, the method will return true. | |
+If not returns false. | |
=head2 as_datetime | |
Formats an internal datetime value into a 'UTC' string suitable for returning to | |
-the client. If parameter is undefined, returns JSON::null. | |
+the client. If parameter is undefined, returns undef. | |
=head2 as_double | |
Takes a number value passed as a parameter, and adds 0.0 to it converting to a | |
-double value. If parameter is undefined, returns JSON::null. | |
+double value. If parameter is undefined, returns undef. | |
=head2 as_email | |
Takes an email address as a parameter. If the user is in the editusers group, | |
it returns the email address, unchanged. If the parameter is undefined or the | |
-user is not in the editusers group, it returns JSON::null. | |
+user is not in the editusers group, it returns undef. | |
=head2 as_int | |
Takes a string or number passed as a parameter and converts it to an integer | |
-value. If parameter is undefined, returns JSON::null. | |
+value. If parameter is undefined, returns undef. | |
=head2 as_int_array | |
@@ -520,7 +520,7 @@ returns an array reference with the converted values. | |
Takes a login name as a parameter. If C<use_email_as_login> is enabled and the | |
user is logged out, it returns the local part of the email address (the part | |
before '@'). Else it returns the full login name. If parameter is undefined, | |
-returns JSON::null. | |
+returns undef. | |
=head2 as_login_array | |
@@ -535,7 +535,7 @@ by calling '$object->name' for each value. | |
=head2 as_string | |
Returns whatever parameter is passed in unchanged, unless undefined, then it | |
-returns JSON::null. | |
+returns undef. | |
=head2 as_string_array | |
diff --git a/Bugzilla/API/Server.pm b/Bugzilla/API/Server.pm | |
index c91c8c9..3dfb256 100644 | |
--- a/Bugzilla/API/Server.pm | |
+++ b/Bugzilla/API/Server.pm | |
@@ -151,7 +151,7 @@ sub return_error { | |
if ($status_code && $message) { | |
$self->{_return_error} = { | |
status_code => $status_code, | |
- error => JSON::true, | |
+ error => \1, | |
message => $message | |
}; | |
$self->{_return_error}->{code} = $error_code if $error_code; | |
@@ -226,7 +226,7 @@ sub _build_json { | |
# This may seem a little backwards to set utf8(0), but what this really | |
# means is "don't convert our utf8 into byte strings, just leave it as a | |
# utf8 string." | |
- return JSON->new->utf8(0) | |
+ return JSON::XS->new->utf8(0) | |
->allow_blessed(1) | |
->convert_blessed(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
--- a/Bugzilla/API/Server.pm
+++ b/Bugzilla/API/Server.pm
@@ -151,7 +151,7 @@ sub return_error {
if ($status_code && $message) {
$self->{_return_error} = {
status_code => $status_code,