Repository navigation
fix: fall back to "All languages" value when ACF applied the field de… - #106
lphoumpakka wants to merge 1 commit into
Conversation
…fault ACF replaces a missing value by the field default_value before acf/load_value. get_default_value() only fell back when the loaded value was null or '', so a true_false field with default_value 0 read as off in every language although enabled for "All languages". Check whether a value is stored for the localized post id (raw metadata via acf_get_metadata_by_field(), or acf_get_metadata() on older ACF) and fall back when nothing is stored. A value saved for the language, even falsy, is kept; non-localized post ids keep the historical behaviour. Add two tests and update CHANGELOG, README and TESTING counters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e3b9321. Configure here.
| * | ||
| * @since 2.0.0 | ||
| */ | ||
| $has_localized_value = $post_id === $original_post_id || $this->has_stored_value( $post_id, $field ); |
There was a problem hiding this comment.
Non-option IDs skip stored-value check
Medium Severity
The new “has a stored localized value” gate is meant to leave non-localized post IDs on the old empty-value path, but it uses $post_id === $original_post_id. For numeric post IDs, original_option_id() returns 0 under Polylang, so that check never matches. get_default_value() still runs on any ACF AJAX request, so an unsaved post field whose value is only the field default_value is treated as missing and replaced via acf_get_value( 0, $field ).
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e3b9321. Configure here.


…fault
ACF replaces a missing value by the field default_value before acf/load_value. get_default_value() only fell back when the loaded value was null or '', so a true_false field with default_value 0 read as off in every language although enabled for "All languages".
Check whether a value is stored for the localized post id (raw metadata via acf_get_metadata_by_field(), or acf_get_metadata() on older ACF) and fall back when nothing is stored. A value saved for the language, even falsy, is kept; non-localized post ids keep the historical behaviour.
Add two tests and update CHANGELOG, README and TESTING counters.
This pull request fixes issue #{id}.
It will apply the following changes :
Note
Medium Risk
Changes front-end option loading for all localized ACF options pages when values are missing or falsy; behavior is covered by new tests but affects a core integration path.
Overview
Fixes multilingual ACF options incorrectly keeping the field
default_value(e.g.true_falsewith default0) instead of the All languages value when nothing is saved for the current language.get_default_value()now decides whether to fall back by checking raw stored metadata for the localized options key via newhas_stored_value()(acf_get_metadata_by_field()on ACF 6.4+, elseacf_get_metadata()), not by treating the loaded$valueas present. Explicitly saved falsy values for a language are still kept.Adds two
Test_Maincases and bumps documented test counts in CHANGELOG, README, and TESTING.Reviewed by Cursor Bugbot for commit e3b9321. Bugbot is set up for automated code reviews on this repo. Configure here.