Repository navigation
fix(local-fields): clear dummy store on toggle - #523
faisalahammad wants to merge 1 commit into
Conversation
Reset the local-empty dummy store in acf_enable_local() and acf_disable_local() so registrations made while local fields are disabled do not accumulate across toggles or leak back when local is re-enabled. Fixes WordPress#459
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for the contribution and the effort here! 🙏 A heads-up on how this repo works: a large part of SCF's codebase (field types, Flexible Content, Blocks v3, local fields, forms, value formatting, and most of includes/ and assets/src/js/) is regularly synced from an upstream codebase. Any change we make there, whether a bug fix or a new feature, gets overwritten or causes hard merge conflicts on the next sync. That includes features behind a beta flag. Fixes for those areas arrive through the sync itself, so we can't accept PRs that touch that code, even good ones. |
Description
When local fields are disabled (via
acf_disable_local()or theacf/settings/localfilter),acf_get_local_store()returns the sharedlocal-emptyACF_Data store. Writes fromacf_add_local_field_group()and friends silently accumulate there, and they are still in that shared store the next time the dummy is reached — for example after re-enabling local.This PR resets the
local-emptystore inside bothacf_enable_local()andacf_disable_local(), so toggle paths discard any registrations that landed while local was disabled.Changes
includes/local-fields.phpReset
acf_get_store( 'local-empty' )after each toggle so registrations made while local is disabled cannot carry across toggle boundaries.Why: The dummy
local-emptystore is the documented fallback when local is disabled, and it is shared between the fields and groups paths. Discarding its contents on toggle is the smallest fix for the leak.tests/php/includes/test-local-fields.phptest_local_setting_filter_disables_localto assert the dummy store is empty afteracf_enable_local()runs.test_disabled_local_clears_dummy_store_on_togglecovering disable → register → enable path.Reproduction
acf/initmu-plugin that setsadd_filter( 'acf/settings/local', '__return_false' )then callsacf_add_local_field_group().acf_get_store( 'local-empty' )->count()returns1.acf_enable_local().local-emptycount is0and the group is not present.Testing
composer test— full PHPUnit suite (2846 tests pass).composer test:phpstan— targeted run on touched files, no errors.composer lint:php— phpcs counts unchanged from baseline.Closes #459
Use of AI Tools
I used AI tooling to help investigate the bug, draft tests, and verify fix coverage. I reviewed and take responsibility for every change in this PR.