fix: prevent undefined array key warning in DistributorPost::get_extra_data#1372
Open
oleksandrhurskyi wants to merge 2 commits into10up:developfrom
Open
fix: prevent undefined array key warning in DistributorPost::get_extra_data#1372oleksandrhurskyi wants to merge 2 commits into10up:developfrom
oleksandrhurskyi wants to merge 2 commits into10up:developfrom
Conversation
fix: prevent undefined array key warning in DistributorPost::get_extra_data
Call populate_source_site() explicitly before accessing source_site array
keys, as __get() magic method is not triggered when the property already
exists. Add null coalescing fallbacks for name and home_url keys to handle
external connections where these values may be absent.
Collaborator
peterwilsoncc
left a comment
There was a problem hiding this comment.
I've added a comment inline.
I've gone through and edited the pull request description to follow the template and clear the warning by the bot.
Are you able to review our Code of Conduct and if you agree check the box in the PR description that you do so?
I can get this merged once that's done.
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
Prevent undefined array key warning in
DistributorPost::get_extra_data()Call
populate_source_site()explicitly at the start ofget_extra_data()before accessing source_site array keys. Direct array access bypasses the__getmagic method when source_site is already a declared but empty property, causing an undefined array key warning on source site save.Added null coalescing fallbacks as a secondary guard.
Fixes #1371
How to test the Change
PHP Warning: Undefined array key "name" in /vagrant/content/plugins/distributor/includes/classes/DistributorPost.php on line 688Changelog Entry
Credits
Props @oleksandrhurskyi, @peterwilsoncc
Checklist: