Skip to content

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Oct 28, 2025

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 init hook). But there's obviously some situations that lead to this not being the case. So this PR adds in a call to populate_fields_array if 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

  1. Install Elementor
  2. Edit a post using Elementor
  3. Notice that on develop, a fatal error will occur
  4. Notice on this PR, the error won't happen

Changelog Entry

Fixed - Ensure the field data is set properly before we use it. Resolves a fatal error with Elementor.

Credits

Props @ktorktor, @dkotter, @peterwilsoncc

Checklist:

@dkotter dkotter added this to the 7.7.0 milestone Oct 28, 2025
@dkotter dkotter self-assigned this Oct 28, 2025
@dkotter dkotter requested a review from jeffpaul as a code owner October 28, 2025 14:18
@github-actions github-actions bot added the needs:code-review This requires code review. label Oct 28, 2025
@dkotter dkotter mentioned this pull request Oct 28, 2025
1 task
@dkotter dkotter requested a review from iamdharmesh October 28, 2025 15:52
@dkotter dkotter modified the milestones: 7.7.0, 7.6.1 Oct 28, 2025
@dkotter dkotter mentioned this pull request Oct 28, 2025
16 tasks
@dkotter dkotter requested review from peterwilsoncc and removed request for iamdharmesh October 28, 2025 19:40
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@dkotter dkotter requested a review from peterwilsoncc October 28, 2025 21:36
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Darin, hitting approve for once the test are complete

@peterwilsoncc peterwilsoncc merged commit 3f2a949 into develop Oct 28, 2025
16 checks passed
@peterwilsoncc peterwilsoncc deleted the fix/370 branch October 28, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The last update broke the site

2 participants