Skip to content

Preserve valid empty and zero values from block bindings - #127

Merged
ingeniumed merged 4 commits into
trunkfrom
ingeniumed/audit-02-binding-values
Nov 19, 2026
Merged

ingeniumed merged 4 commits into
trunkfrom
ingeniumed/audit-02-binding-values

Conversation

@ingeniumed

Copy link
Copy Markdown
Contributor

Description

When a block binding returns an empty string, zero, false, or a value equal to the attribute default, the parser can mistake that valid result for a missing binding and overwrite it with saved HTML.

For example, clearing a field used by core/post-meta can leave REST and GraphQL returning the old text saved in the block instead of the empty value.

Track attributes successfully resolved by WordPress during rendering and preserve those values during extraction. Follow core’s behavior of treating only null as unresolved, without calling binding sources again.

Binding result Before After
Empty string, zero, false, or default-matching value May return saved HTML instead Preserve the value resolved by core
Null or missing source Fall back to saved HTML Same fallback behavior

This also covers synced-pattern children. Temporary observers are removed when rendering throws. Screenshots are not applicable to this API change.

Steps to Test

Run against WordPress 6.8, 6.9 and 7.1:

composer phpcs
composer test
composer test-multisite

Regression tests cover valid binding values, fallback behavior, synced patterns, filtered values, source-call counts and cleanup after exceptions.

@ingeniumed
ingeniumed requested a review from a team as a code owner November 18, 2026 02:38
@ingeniumed ingeniumed self-assigned this Nov 18, 2026
Comment thread src/parser/content-parser.php Resolved
alecgeatches
alecgeatches previously approved these changes Nov 19, 2026

@alecgeatches alecgeatches 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.

Minor comment suggestion, otherwise good to go!

@ingeniumed
ingeniumed merged commit 4d8778b into trunk Nov 19, 2026
20 checks passed
@ingeniumed
ingeniumed deleted the ingeniumed/audit-02-binding-values branch November 19, 2026 20:29
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.

2 participants