[wp-trac] [WordPress Trac] #51082: Default value for comment_type changed can lead to comments not shown

WordPress Trac noreply at wordpress.org
Thu Aug 20 14:58:05 UTC 2020


#51082: Default value for comment_type changed can lead to comments not shown
--------------------------+-----------------------------
 Reporter:  Ov3rfly       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  5.5
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Had a situation where a theme would not show comments any more with WP
 5.5, it would show correct number of comments but not the comments
 content. Using 5.4.2 backup made the comments appear again.

 After some research found this remark at `wp_insert_comment()`

 {{{
 @since 5.5.0 Default value for `$comment_type` argument changed to
 `comment`.
 }}}

 The theme in question uses a callback function for `wp_list_comments()`
 with this code:

 {{{
 switch ( $comment->comment_type ) :
         case '' :
                 // print normal comment here...
                 break;
         case 'pingback'  :
         case 'trackback' :
                 break;
 endswitch;
 }}}

 That causes the comments not to be shown because `$comment->comment_type`
 is `'comment'` with WP 5.5 and not an empty string any more.

 Many themes with callbacks including Twenty Twelve, Twenty Eleven compare
 to `'pingback'` and `'trackback'` first and then as `default` case print
 normal comment, without checking real value of `$comment->comment_type`.

 That's why the new behaviour of WP 5.5 accidentally works with many
 themes.

 For backward compatibility `$comment->comment_type` should be set to empty
 string instead `'comment'` when using a callback or a deprecated notice or
 similar should be triggered.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51082>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list