Skip to content

REST API: Preserve meta change events in client helpers - #13955

Open
qorud02 wants to merge 1 commit into
WordPress:trunkfrom
qorud02:codex/rest-api-meta-change-events
Open

qorud02 wants to merge 1 commit into
WordPress:trunkfrom
qorud02:codex/rest-api-meta-change-events

Conversation

@qorud02

@qorud02 qorud02 commented Oct 3, 2026

Copy link
Copy Markdown

The REST API client's setMeta() and setMetas() mutate the model's existing metadata object before passing it to Backbone's set(). The comparison then sees the same object and does not emit change:meta. When metadata is missing, the single setter throws and the plural setter does not retain the supplied values.

Copy the existing metadata into a new object before updating it. This preserves other keys and the previous model value, emits an event when metadata changes, and keeps unchanged values silent.

Add QUnit coverage for both setters: initializing missing metadata, updating existing metadata, preserving other keys and previous values, and suppressing redundant events.

Trac ticket: https://core.trac.wordpress.org/ticket/43149

Testing:

  • The isolated regressions execute the actual Core mixin and test block: the baseline fails both tests; the patch passes both tests (16 assertions).
  • The complete wp-api.js QUnit test file, with Core's real schema and AJAX fixtures, passes 152/152 assertions through the unchanged official Playwright QUnit runner. A focused HTML page loads these assets; this is the API client suite, not the entire Core JavaScript suite.
  • node --check for both changed JavaScript files and git diff --check pass.
  • Runtime: Node 24.21.0, npm 11.19.0, Playwright 1.61.1, Backbone 1.6.1, Underscore 1.13.8.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Used for: Repository investigation, patch and regression-test preparation, and automated local verification. Human maintainer review is requested before acceptance.


This pull request is for code review only. Please keep other discussion in the Trac ticket. Do not merge this pull request.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @qorud02.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant