-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set empty props as objects in WPCOM Proxy responses #2519
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2519 +/- ##
============================================
+ Coverage 63.8% 65.0% +1.3%
- Complexity 0 4585 +4585
============================================
Files 323 475 +152
Lines 5052 17898 +12846
Branches 1222 0 -1222
============================================
+ Hits 3222 11640 +8418
- Misses 1664 6258 +4594
+ Partials 166 0 -166
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @puntope for working on this. I left a comment about calling get_data
and set_data
without checking the $response type.
@@ -169,36 +169,59 @@ function ( $response, $handler, $request ) { | |||
return $response; | |||
} | |||
|
|||
$data = $response->get_data(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $response
can be one of these types: WP_REST_Response
, WP_HTTP_Response
, WP_Error
, or mixed
. If $response
isn't a WP_REST_Response
, it will throw an error because get_data
or set_data
might no be defined.
Thx @jorgemd24 I updated the code so now it returns early if the response is not WP_REST_Response. Can you take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @puntope for the adjustment. LGTM 👍
Changes proposed in this Pull Request:
Context: p1723540799285679/1722414955.111429-slack-C02BB3F30TG
In this PR we convert empty array properties into empty objects.
Screenshots:
Detailed test instructions:
$data['test'] = []
; in the first line of the newprepare_data()
function to simulate we get an empty array in a prop.Additional details:
Changelog entry