Skip to content

Harden radio save_other_choice lookup for JSON fields#382

Open
meravi wants to merge 2 commits intoWordPress:trunkfrom
meravi:fix/radio-save-other-choice-guards
Open

Harden radio save_other_choice lookup for JSON fields#382
meravi wants to merge 2 commits intoWordPress:trunkfrom
meravi:fix/radio-save-other-choice-guards

Conversation

@meravi
Copy link

@meravi meravi commented Mar 10, 2026

Summary

This hardens acf_field_radio::update_value() when save_other_choice is enabled and the runtime field is JSON-only or missing identifiers.

Changes

  • Guard selector resolution (ID -> key -> bail early).
  • Bail if acf_get_field() fails or returns a field without DB ID.
  • Normalize choices to an array before appending custom values.
  • Add regression tests for JSON-only/missing-identifier edge cases.

Tests

  • Added:
    • test_update_value_save_other_choice_handles_json_field_without_id
    • test_update_value_save_other_choice_handles_missing_field_identifier

Fixes #381

@github-actions
Copy link

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ravikhadka.

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

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.

Radio save_other_choice triggers warnings for JSON-only or unidentified fields

1 participant