Description
The preview paths of acf_rendered_block() / acf_rendered_block_v3() call acf_setup_meta() for post-render validation but never call the matching acf_reset_meta(), leaving block-scoped local meta active after the function returns.
This compounds badly with how local meta works: while acf_setup_meta() is active for a post id, ACF_Local_Meta's pre_load_metadata filter returns __return_null for any meta name not present in the local set (includes/local-meta.php:194-203) — shadowing real database values for that post. So after a block preview render, unrelated get_field() calls for the same post id can silently return null.
Affected code
includes/blocks.php (acf_rendered_block / acf_rendered_block_v3 preview paths)
- Interplay:
includes/local-meta.php:194-203
Reproduction
Repro documented in #450: tests/php/includes/blocks/test-blocks-render.php (tear_down resets the leaked state manually and carries the NOTE comment); the shadowing behavior itself is characterized in tests/php/includes/test-local-meta.php (test_local_meta_shadows_missing_names).
Suggested fix
Pair every acf_setup_meta() in the preview/validation paths with acf_reset_meta() (try/finally semantics or immediately after the validation read).
Found during the 2026-06 test campaign (see PR #450).
Description
The preview paths of
acf_rendered_block()/acf_rendered_block_v3()callacf_setup_meta()for post-render validation but never call the matchingacf_reset_meta(), leaving block-scoped local meta active after the function returns.This compounds badly with how local meta works: while
acf_setup_meta()is active for a post id,ACF_Local_Meta'spre_load_metadatafilter returns__return_nullfor any meta name not present in the local set (includes/local-meta.php:194-203) — shadowing real database values for that post. So after a block preview render, unrelatedget_field()calls for the same post id can silently returnnull.Affected code
includes/blocks.php(acf_rendered_block/acf_rendered_block_v3preview paths)includes/local-meta.php:194-203Reproduction
Repro documented in #450:
tests/php/includes/blocks/test-blocks-render.php(tear_down resets the leaked state manually and carries the NOTE comment); the shadowing behavior itself is characterized intests/php/includes/test-local-meta.php(test_local_meta_shadows_missing_names).Suggested fix
Pair every
acf_setup_meta()in the preview/validation paths withacf_reset_meta()(try/finally semantics or immediately after the validation read).Found during the 2026-06 test campaign (see PR #450).