Repository navigation
Collaboration: Return a WP_REST_Response from the sync save handler - #86098
Conversation
`WP_Sync_Save_Server::handle_request()` is documented to return `WP_REST_Response|WP_Error` but returned a plain array on success. Wrap it in a `WP_REST_Response`, which is what the REST server would produce from the array anyway. Remove the resolved entry from the PHPStan baseline. See WordPress#86088.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change aligning the sync-save handler’s success response with its documented return type.
No open issues 🎉
What changed in this PR
Aligns the collaboration sync-save handler with its documented return type, resolving one PHPStan baseline error tracked in #86088.
Changes:
- Returns an empty
WP_REST_Responseon success while preserving the REST response data. - Removes the corresponding
return.typesuppression.
| File | Description |
|---|---|
tools/phpstan/baseline.neon |
Removes the resolved return-type error entry. |
lib/experimental/collaboration/class-wp-sync-save-server.php |
Returns WP_REST_Response instead of a plain array on success. |
Review effort: Balanced
im3dabasia
left a comment
There was a problem hiding this comment.
Thanks! This matches the documented return type, and the response clients get is unchanged. 👍
CI is 🟢 too!
…ix/phpstan-lib-experimental
What?
See #86088
Makes
WP_Sync_Save_Server::handle_request()return aWP_REST_Responseon success, as documented, and removes the resolved entry from the PHPStan baseline.Why?
The method is documented to return
WP_REST_Response|WP_Error, but returned a plainarray()on success, which PHPStan reports asreturn.type. This resolves 1 of the 226 errors initially baselined in #66693.How?
return array();withreturn new WP_REST_Response( array() );. The REST server passes callback results throughrest_ensure_response(), which wraps an array in aWP_REST_Responseanyway, so the response is unchanged.tools/phpstan/baseline.neon.The existing test in
phpunit/tests/collaboration/wpSyncSaveServer.phpalready asserts that the response data is an empty array.Testing Instructions
composer phpstanand confirm it passes with no unmatched ignored errors.npm run test:php -- --filter Tests_Collaboration_WpSyncSaveServer.Testing Instructions for Keyboard
Not applicable. There are no UI changes.
Screenshots or screencast
Not applicable.
Use of AI Tools
I used Claude Code to identify the affected occurrences and draft the change. I reviewed the diff and take responsibility for it.