Skip to content

Collaboration: Return a WP_REST_Response from the sync save handler - #86098

Merged
westonruter merged 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:fix/phpstan-lib-experimental
Nov 6, 2026
Merged

westonruter merged 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:fix/phpstan-lib-experimental

Conversation

@huzaifaalmesbah

@huzaifaalmesbah huzaifaalmesbah commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What?

See #86088

Makes WP_Sync_Save_Server::handle_request() return a WP_REST_Response on 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 plain array() on success, which PHPStan reports as return.type. This resolves 1 of the 226 errors initially baselined in #66693.

How?

  • Replaced return array(); with return new WP_REST_Response( array() );. The REST server passes callback results through rest_ensure_response(), which wraps an array in a WP_REST_Response anyway, so the response is unchanged.
  • Removed the corresponding entry from tools/phpstan/baseline.neon.

The existing test in phpunit/tests/collaboration/wpSyncSaveServer.php already asserts that the response data is an empty array.

Testing Instructions

  1. Run composer phpstan and confirm it passes with no unmatched ignored errors.
  2. Run the collaboration tests: 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.

`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.
@huzaifaalmesbah huzaifaalmesbah added the [Type] Code Quality Issues or PRs that relate to code quality label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: huzaifaalmesbah <huzaifaalmesbah@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_Response on success while preserving the REST response data.
  • Removes the corresponding return.type suppression.
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 im3dabasia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This matches the documented return type, and the response clients get is unchanged. 👍

CI is 🟢 too!

@westonruter
westonruter enabled auto-merge (squash) November 6, 2026 07:55
@westonruter
westonruter merged commit 0102954 into WordPress:trunk Nov 6, 2026
93 of 95 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants