Fix undefined property warning in Item::__call magic method#544
Merged
Fix undefined property warning in Item::__call magic method#544
Conversation
30ccbca to
af296a8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes undefined property warnings that occur in PHP when the Item::__call magic method attempts to access properties that don't exist on the class, such as category. The fix adds property_exists() checks before property access in the getter, checker, and adder methods.
- Adds
property_exists()guards to prevent undefined property warnings in magic method handlers - Uses proper short-circuit evaluation to ensure properties are only accessed when they exist
- Maintains backward compatibility by preserving the same behavior while eliminating warnings
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| includes/Entity/class-item.php | Adds property_exists() checks in get, has, and add magic method branches to prevent accessing undefined properties |
| readme.md | Documents the bug fix in version 5.5.1 changelog |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dshanske
requested changes
Dec 14, 2025
Add property_exists() checks before accessing dynamic properties in get, has, and add methods. Return empty string instead of null for non-existent properties.
15082d4 to
1243a4c
Compare
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.
Summary
property_exists()checks before accessing dynamic properties inget,has, andaddmethodsadd_category()are called for properties that don't exist on the classTest plan
/wp-json/webmention/1.0/endpointFixes #541