Ensure fields are set before we use them#371
Merged
peterwilsoncc merged 2 commits intodevelopfrom Oct 28, 2025
Merged
Conversation
Contributor
peterwilsoncc
left a comment
There was a problem hiding this comment.
This looks good to me and tests well.
In ::admin_init the plugin uses both of the values without calling ::populate_fields_array() in a for each loop, should we add a logic check there too?
peterwilsoncc
approved these changes
Oct 28, 2025
Contributor
peterwilsoncc
left a comment
There was a problem hiding this comment.
Thanks Darin, hitting approve for once the test are complete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
As reported in #370, there's a situation that can arise where the fields data we want to use isn't set properly and so when we try and use it, this causes errors.
Note I wasn't able to reproduce this myself and in looking at the code, it seems this data should always be set before we try using it (it gets set on the
inithook). But there's obviously some situations that lead to this not being the case. So this PR adds in a call topopulate_fields_arrayif that data isn't set to ensure it gets set before we use it. This same approach is used in multiple places across the plugin so seems like an issue we've run into before.Edit: was able to reproduce using Elementor so seems a conflict with them (and potentially other plugins). Did verify that the fix here solves things though.
Closes #370
How to test the Change
develop, a fatal error will occurChangelog Entry
Credits
Props @ktorktor, @dkotter, @peterwilsoncc
Checklist: