-
Notifications
You must be signed in to change notification settings - Fork 805
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
Connection: Add REST support for jsonAPI endpoints #39432
base: trunk
Are you sure you want to change the base?
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
1b9fbb2
to
a3cc273
Compare
9633b2c
to
bb92f7a
Compare
Hi @fgiannar |
I believe we also need to copy the output logic from |
} | ||
|
||
if ( $request->get_param( 'http_envelope' ) ) { | ||
$response = wp_json_encode( WPCOM_JSON_API::wrap_http_envelope( $status_code, $response, 'application/json' ) ); |
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.
I believe we need to json encode the response independently of the http_envelope
param. Otherwise, we get a PHP Warning locally: PHP Warning: Array to string conversion in class.json-api-endpoints.php on line 2740
and a Fatal on WPCOM: Fatal error: Uncaught Error: Object of class stdClass could not be converted to string
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.
Good catch, thanks!
Fixed now: c9f0973
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.
Looks like we are encoding the $response
twice if http_envelope
is true
. Is that ok? Should we perhaps do something like:
if ( $request->get_param( 'http_envelope' ) ) {
$response = WPCOM_JSON_API::wrap_http_envelope( $status_code, $response, 'application/json' );
}
$response = wp_json_encode( $response );
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.
Good catch, there really is no need for that.
Removed in dd50616
Adjusted the WPCOM counterpart as well.
Proposed changes:
Other information:
Jetpack product discussion
pf5801-18d-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
See 169495-ghe-Automattic/wpcom