[wp-trac] [WordPress Trac] #49236: Use 'comment' instead of '' for the comment_type db field for comments

WordPress Trac noreply at wordpress.org
Fri Aug 21 10:09:39 UTC 2020


#49236: Use 'comment' instead of '' for the comment_type db field for comments
-------------------------------------------------+-------------------------
 Reporter:  imath                                |       Owner:
                                                 |  SergeyBiryukov
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  5.5
Component:  Comments                             |     Version:  5.4
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch early commit has-dev-note  |     Focuses:
  dev-reviewed                                   |
-------------------------------------------------+-------------------------

Comment (by Ov3rfly):

 Posting this here as this ticket was refered to in #51082 by @jeremyfelt

 > .. Twenty Ten had to be updated to take the new type into account and
 ensure that new comments get displayed properly ..

 Actually Twenty Ten and some other themes out there did it right.

 They check the actual value of `comment_type`, an empty string is a valid
 value.

 Any new comment type would be not shown - as expected.

 Most other themes including Twenty Eleven, Twenty Twelve and hundreds more
 https://wpdirectory.net/search/01EG85WWS35NAC1V7GH59XN2MW are **doing it
 wrong**.

 They use callbacks with this code:

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

 These themes still "work" with the new behaviour of WP 5.5 but that's
 **accidentally** only and can/will lead to unexpected results if ever a
 new `comment_type` will be introduced - each and every theme will have to
 be updated.

 The correct way to implement this custom comment enhancement would be:

 * Add a deprecated notice if `callback` param is used, keep rest of code
 for the time being.

 * Add new param `callback_new` which can be used by themes to handle all
 including new comment types in future.

 * Provide example code with `callback_new` in Twenty XXX which checks
 actual value of `comment_type`, including a check for empty string, and
 has no/empty default case.

 There imho was no need at all to change the default value of
 `comment_type` and now mess around in years old rows in huge databases
 with unknown side effects and still get unexpected results with above
 mentioned themes without extra updates there...

 Would urgently suggest to rethink this whole approach.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49236#comment:36>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list