Skip to content

Conversation

@pfefferle
Copy link
Owner

Summary

  • Add property_exists() checks before accessing dynamic properties in get, has, and add methods
  • Prevents PHP warnings when methods like add_category() are called for properties that don't exist on the class

Test plan

  • Verify no more "Undefined property" warnings at /wp-json/webmention/1.0/endpoint
  • Test webmention processing still works correctly

Fixes #541

Add property_exists() checks before accessing dynamic properties in
get, has, and add methods to prevent PHP warnings when methods like
add_category() are called for properties that don't exist on the class.

Fixes #541
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undefined property: Webmention\Entity\Item::$category

2 participants