Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #54607


Ignore:
Timestamp:
12/11/2021 12:18:42 AM (4 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #54607

    • Property Keywords php8 added
    • Property Milestone changed from Awaiting Review to 6.0
  • Ticket #54607 – Description

    initial v2  
    11PHP 8 reports warning when we try to access properties of null object.
    2 I see such thing in my Wordpress:
     2I see such thing in my WordPress:
    33
    4 FastCGI sent in stderr: "PHP message: PHP Warning:  Attempt to read property "comment_ID" on null in /website/wp-includes/comment-template.php on line 677PHP message: PHP Warning:  Attempt to read property "user_id" on null in /website/wp-includes/comment-template.php on line 28PHP message: PHP Warning:  Attempt to read property "comment_ID" on null in /website/wp-includes/comment-template.php on line 48" while reading response header from upstream ... request: "GET /website/?replytocom=15958
     4FastCGI sent in stderr:
     5"PHP message: PHP Warning:  Attempt to read property "comment_ID" on null in /website/wp-includes/comment-template.php on line 677
     6PHP message: PHP Warning:  Attempt to read property "user_id" on null in /website/wp-includes/comment-template.php on line 28
     7PHP message: PHP Warning:  Attempt to read property "comment_ID" on null in /website/wp-includes/comment-template.php on line 48"
     8while reading response header from upstream ... request: "GET /website/?replytocom=15958
    59
    610The code is:
     11{{{
    712     $comment = get_comment();
    813     return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
    9 
     14}}}
    1015There is no check if $comment is null.
    1116
    1217But when we check the source code of get_comment we see such code:
     18{{{
    1319     if ( ! $_comment ) {
    1420        return null;
    1521     }
    16 
     22}}}
    1723So get_comment may return null, but the function get_comment_ID blindly tries to access properties of null objects.