Skip to content

Fix PHP 8 TypeError in parse_post_json when JSON is invalid#566

Merged
pfefferle merged 1 commit intomainfrom
fix/php8-null-array-handling
Dec 18, 2025
Merged

Fix PHP 8 TypeError in parse_post_json when JSON is invalid#566
pfefferle merged 1 commit intomainfrom
fix/php8-null-array-handling

Conversation

@pfefferle
Copy link
Copy Markdown
Owner

Summary

  • Add is_array() check before accessing JSON data to prevent fatal error when json_decode() returns null
  • Use isset() for date and modified keys to prevent "undefined array key" warnings in PHP 8+

Fixes #564

Test plan

  • Send a webmention from a source that returns invalid JSON
  • Verify no PHP fatal error or warnings occur
  • Verify webmentions from valid WordPress REST API sources still work correctly

Add is_array() check before accessing JSON data to prevent fatal error
when json_decode returns null. Also use isset() for date and modified
keys to prevent "undefined array key" warnings.

Fixes #564
@pfefferle pfefferle merged commit 555f4cd into main Dec 18, 2025
9 checks passed
@pfefferle pfefferle deleted the fix/php8-null-array-handling branch December 18, 2025 18:24
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.

PHP 8 depreiciation possibly causes critical error - error not present with PHP 7.4

2 participants