Ensure fields are set before we use them #371
Merged
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: