Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outbox: Account for invalid json #1230

Merged
merged 3 commits into from
Jan 29, 2025
Merged

Conversation

obenland
Copy link
Member

@obenland obenland commented Jan 28, 2025

Not quite sure this is the best way to go. I'd be fine with restoring init_from_json() to working with an empty array, too.

See p1738085487855409/1738079794.569609-slack-C04TJ8P900J

PHP Fatal error:  Uncaught Error: Call to undefined method WP_Error::set__id() in /wp-content/plugins/activitypub/includes/model/class-follower.php:339
Stack trace:
#0 /wp-content/plugins/activitypub/includes/collection/class-followers.php(202): Activitypub\Model\Follower::init_from_cpt(Object(WP_Post))

Proposed changes:

  • Adds WP Error checks to all calls of init_from_json().
  • Adds test to cover the possibility of invalid json.

Other information:

  • Have you written new tests for your changes, if applicable?

@obenland obenland added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Jan 28, 2025
@obenland obenland requested review from pfefferle and jeherve January 28, 2025 18:22
@obenland obenland self-assigned this Jan 28, 2025
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

That fixes it, thank you!

@obenland obenland merged commit 86523f0 into add/outbox-collection Jan 29, 2025
11 checks passed
@obenland obenland deleted the fix/invalide-json branch January 29, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Collections Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants