Skip to content

Conversation

@maxheadroom
Copy link

Prevent "Cannot use object of type WP_Error as array" by initializing $author as an empty array upfront and only populating it if the HTTP request succeeds. This ensures $author is always an array, allowing the code to gracefully fall back when the remote request fails.

Fixes #

Proposed changes:

  • preventing a PHP fatal error if the web finger request does not succeed and thus $author is empty

Other information:

Testing instructions:

I believe this happens when Mastodon Posts are embedded in a Blog post via the Embed block and the remote server is too slow to answer.

Changelog entry

Prevent "Cannot use object of type WP_Error as array" by initializing
$author as an empty array upfront and only populating it if the HTTP
request succeeds. This ensures $author is always an array, allowing the
code to gracefully fall back when the remote request fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants