Skip to content

Fix: add null check for comment in wp_cache_get_postid_from_comment()#1043

Open
DeveloperBatuhanALGUL wants to merge 1 commit intoAutomattic:trunkfrom
DeveloperBatuhanALGUL:fix/null-comment-check-in-postid-from-comment
Open

Fix: add null check for comment in wp_cache_get_postid_from_comment()#1043
DeveloperBatuhanALGUL wants to merge 1 commit intoAutomattic:trunkfrom
DeveloperBatuhanALGUL:fix/null-comment-check-in-postid-from-comment

Conversation

@DeveloperBatuhanALGUL
Copy link
Copy Markdown

Fixes #1014

get_comment() returns null when a comment has already been deleted by
the time the cache-clear routine runs. The existing code attempts to
access array offsets on that null value immediately after, which
triggers a PHP Warning on PHP 8.x.

This adds an early return right after get_comment() so the function
exits cleanly when the comment no longer exists, rather than
proceeding with a null value and generating noise in the error log.

Tested on PHP 8.3.8 / WordPress 6.7 / WP Super Cache 3.1.0.

get_comment() can return null when a comment has already been deleted
by the time the cache-clear routine runs. This adds an early return to
skip the cache update gracefully instead of triggering a PHP warning.
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 Warning in wp-cache-phase2.php: Array Offset on Null

1 participant