<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[47597] trunk: Comments: Use `comment` instead of an empty string for the `comment_type` DB field value in comments table.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/47597">47597</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/47597","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-04-17 19:33:52 +0000 (Fri, 17 Apr 2020)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Comments: Use `comment` instead of an empty string for the `comment_type` DB field value in comments table.

This is the first step to bring support for custom comment types into WordPress.

Add a scheduled upgrade routine to update the type value for existing comments, in batches of 100 at a time.

Props imath, aaroncampbell, jeremyfelt, dshanske.
Fixes <a href="https://core.trac.wordpress.org/ticket/49236">#49236</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludesschemaphp">trunk/src/wp-admin/includes/schema.php</a></li>
<li><a href="#trunksrcwpadminincludesupgradephp">trunk/src/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentytenfunctionsphp">trunk/src/wp-content/themes/twentyten/functions.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcommentqueryphp">trunk/src/wp-includes/class-wp-comment-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcommentphp">trunk/src/wp-includes/class-wp-comment.php</a></li>
<li><a href="#trunksrcwpincludescommentphp">trunk/src/wp-includes/comment.php</a></li>
<li><a href="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php</a></li>
<li><a href="#trunksrcwpincludesversionphp">trunk/src/wp-includes/version.php</a></li>
<li><a href="#trunktestsphpunittestscommentsubmissionphp">trunk/tests/phpunit/tests/comment-submission.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php      2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-admin/includes/ajax-actions.php        2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1283,7 +1283,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $comment_author_email = wp_slash( $user->user_email );
</span><span class="cx" style="display: block; padding: 0 10px">                $comment_author_url   = wp_slash( $user->user_url );
</span><span class="cx" style="display: block; padding: 0 10px">                $comment_content      = trim( $_POST['content'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $comment_type         = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $comment_type         = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : 'comment';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( current_user_can( 'unfiltered_html' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
</span></span></pre></div>
<a id="trunksrcwpadminincludesschemaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/schema.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/schema.php    2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-admin/includes/schema.php      2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,7 +111,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        comment_karma int(11) NOT NULL default '0',
</span><span class="cx" style="display: block; padding: 0 10px">        comment_approved varchar(20) NOT NULL default '1',
</span><span class="cx" style="display: block; padding: 0 10px">        comment_agent varchar(255) NOT NULL default '',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        comment_type varchar(20) NOT NULL default '',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ comment_type varchar(20) NOT NULL default 'comment',
</ins><span class="cx" style="display: block; padding: 0 10px">         comment_parent bigint(20) unsigned NOT NULL default '0',
</span><span class="cx" style="display: block; padding: 0 10px">        user_id bigint(20) unsigned NOT NULL default '0',
</span><span class="cx" style="display: block; padding: 0 10px">        PRIMARY KEY  (comment_ID),
</span></span></pre></div>
<a id="trunksrcwpadminincludesupgradephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/upgrade.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/upgrade.php   2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-admin/includes/upgrade.php     2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -283,6 +283,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'comment_date'         => $now,
</span><span class="cx" style="display: block; padding: 0 10px">                                'comment_date_gmt'     => $now_gmt,
</span><span class="cx" style="display: block; padding: 0 10px">                                'comment_content'      => $first_comment,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'comment_type'         => 'comment',
</ins><span class="cx" style="display: block; padding: 0 10px">                         )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -834,6 +835,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                upgrade_530();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( $wp_current_db_version < 47597 ) {
+               upgrade_550();
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         maybe_disable_link_manager();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        maybe_disable_automattic_widgets();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2155,6 +2160,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Executes changes made in WordPress 5.5.0.
+ *
+ * @ignore
+ * @since 5.5.0
+ */
+function upgrade_550() {
+       update_option( 'finished_updating_comment_type', 0 );
+       wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Executes network-level upgrade routines.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 3.0.0
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentytenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentyten/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentyten/functions.php       2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-content/themes/twentyten/functions.php 2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -418,6 +418,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $GLOBALS['comment'] = $comment;
</span><span class="cx" style="display: block; padding: 0 10px">                switch ( $comment->comment_type ) :
</span><span class="cx" style="display: block; padding: 0 10px">                        case '':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        case 'comment':
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ?>
</span><span class="cx" style="display: block; padding: 0 10px">                <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
</span><span class="cx" style="display: block; padding: 0 10px">                <div id="comment-<?php comment_ID(); ?>">
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcommentqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-comment-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-comment-query.php  2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-includes/class-wp-comment-query.php    2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -741,7 +741,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        case 'comment':
</span><span class="cx" style="display: block; padding: 0 10px">                                        case 'comments':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                $comment_types[ $operator ][] = "''";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         $comment_types[ $operator ][] = "'comment'";
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 break;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        case 'pings':
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcommentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-comment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-comment.php        2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-includes/class-wp-comment.php  2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,9 +114,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * Comment type.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 4.4.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.5.0 Default value changed to `comment`.
</ins><span class="cx" style="display: block; padding: 0 10px">          * @var string
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public $comment_type = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $comment_type = 'comment';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Parent comment ID.
</span></span></pre></div>
<a id="trunksrcwpincludescommentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/comment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/comment.php 2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-includes/comment.php   2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1853,7 +1853,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Inserts a comment into the database.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.0.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 4.4.0 Introduced `$comment_meta` argument.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0 Introduced the `$comment_meta` argument.
+ * @since 5.5.0 Default value for `$comment_type` argument changed to `comment`.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @global wpdb $wpdb WordPress database abstraction object.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1877,7 +1878,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type int        $comment_parent       ID of this comment's parent, if any. Default 0.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type int        $comment_post_ID      ID of the post that relates to the comment, if any.
</span><span class="cx" style="display: block; padding: 0 10px">  *                                            Default 0.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *     @type string     $comment_type         Comment type. Default empty.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *     @type string     $comment_type         Comment type. Default 'comment'.
</ins><span class="cx" style="display: block; padding: 0 10px">  *     @type array      $comment_meta         Optional. Array of key/value pairs to be stored in commentmeta for the
</span><span class="cx" style="display: block; padding: 0 10px">  *                                            new comment.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type int        $user_id              ID of the user who submitted the comment. Default 0.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1901,7 +1902,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $comment_karma    = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma'];
</span><span class="cx" style="display: block; padding: 0 10px">        $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved'];
</span><span class="cx" style="display: block; padding: 0 10px">        $comment_agent    = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $comment_type     = ! isset( $data['comment_type'] ) ? '' : $data['comment_type'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comment_type     = ! isset( $data['comment_type'] ) ? 'comment' : $data['comment_type'];
</ins><span class="cx" style="display: block; padding: 0 10px">         $comment_parent   = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent'];
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2043,9 +2044,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * See {@link https://core.trac.wordpress.org/ticket/9235}
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 1.5.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 4.3.0 'comment_agent' and 'comment_author_IP' can be set via `$commentdata`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.3.0 Introduced the `comment_agent` and `comment_author_IP` arguments.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function to
</span><span class="cx" style="display: block; padding: 0 10px">  *              return a WP_Error object instead of dying.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.5.0 Introduced the `comment_type` argument.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @see wp_insert_comment()
</span><span class="cx" style="display: block; padding: 0 10px">  * @global wpdb $wpdb WordPress database abstraction object.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2060,6 +2062,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type string $comment_date         The date the comment was submitted. Default is the current time.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type string $comment_date_gmt     The date the comment was submitted in the GMT timezone.
</span><span class="cx" style="display: block; padding: 0 10px">  *                                        Default is `$comment_date` in the GMT timezone.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *     @type string $comment_type         Comment type. Default 'comment'.
</ins><span class="cx" style="display: block; padding: 0 10px">  *     @type int    $comment_parent       The ID of this comment's parent, if any. Default 0.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type int    $comment_post_ID      The ID of the post that relates to the comment.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type int    $user_id              The ID of the user who submitted the comment. Default 0.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2122,6 +2125,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( empty( $commentdata['comment_type'] ) ) {
+               $commentdata['comment_type'] = 'comment';
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $commentdata = wp_filter_comment( $commentdata );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3348,7 +3355,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $comment_type = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comment_type = 'comment';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( '' == $comment_author_email || '' == $comment_author ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3636,3 +3643,73 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_cache_set_comments_last_changed() {
</span><span class="cx" style="display: block; padding: 0 10px">        wp_cache_set( 'last_changed', microtime(), 'comment' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Updates the comment type for a batch of comments.
+ *
+ * @since 5.5.0
+ *
+ * @global wpdb $wpdb WordPress database abstraction object.
+ */
+function _wp_batch_update_comment_type() {
+       global $wpdb;
+
+       $lock_name = 'update_comment_type.lock';
+
+       // Try to lock.
+       $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
+
+       if ( ! $lock_result ) {
+               $lock_result = get_option( $lock_name );
+
+               // Bail if we were unable to create a lock, or if the existing lock is still valid.
+               if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
+                       wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
+                       return;
+               }
+       }
+
+       // Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
+       update_option( $lock_name, time() );
+
+       // Check if there's still an empty comment type.
+       $empty_comment_type = $wpdb->get_var(
+               "SELECT comment_ID FROM $wpdb->comments
+               WHERE comment_type = ''
+               LIMIT 1"
+       );
+
+       // No empty comment type, we're done here.
+       if ( ! $empty_comment_type ) {
+               update_option( 'finished_updating_comment_type', true );
+               delete_option( $lock_name );
+               return;
+       }
+
+       // Empty comment type found? We'll need to run this script again.
+       wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
+
+       // Update the `comment_type` field value to be `comment` for the next 100 rows of comments.
+       $wpdb->query(
+               "UPDATE {$wpdb->comments}
+               SET comment_type = 'comment'
+               WHERE comment_type = ''
+               ORDER BY comment_ID DESC
+               LIMIT 100"
+       );
+
+       delete_option( $lock_name );
+}
+
+/**
+ * In order to avoid the _wp_batch_update_comment_type() job being accidentally removed,
+ * check that it's still scheduled while we haven't finished updating comment types.
+ *
+ * @ignore
+ * @since 5.5.0
+ */
+function _wp_check_for_scheduled_update_comment_type() {
+       if ( ! get_option( 'finished_updating_comment_type' ) && ! wp_next_scheduled( 'wp_update_comment_type_batch' ) ) {
+               wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_update_comment_type_batch' );
+       }
+}
</ins></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-includes/default-filters.php   2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -438,6 +438,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Comment type updates.
+add_action( 'admin_init', '_wp_check_for_scheduled_update_comment_type' );
+add_action( 'wp_update_comment_type_batch', '_wp_batch_update_comment_type' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Email notifications.
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php    2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php      2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -585,7 +585,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return $prepared_comment;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $prepared_comment['comment_type'] = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $prepared_comment['comment_type'] = 'comment';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /*
</span><span class="cx" style="display: block; padding: 0 10px">                 * Do not allow a comment to be created with missing or empty
</span></span></pre></div>
<a id="trunksrcwpincludesversionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/version.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/version.php 2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/src/wp-includes/version.php   2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,7 +20,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @global int $wp_db_version
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$wp_db_version = 47018;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$wp_db_version = 47597;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Holds the TinyMCE version.
</span></span></pre></div>
<a id="trunktestsphpunittestscommentsubmissionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/comment-submission.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment-submission.php  2020-04-17 18:53:33 UTC (rev 47596)
+++ trunk/tests/phpunit/tests/comment-submission.php    2020-04-17 19:33:52 UTC (rev 47597)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -742,7 +742,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'comment_author_email' => $user->user_email,
</span><span class="cx" style="display: block; padding: 0 10px">                                'comment_author_url'   => $user->user_url,
</span><span class="cx" style="display: block; padding: 0 10px">                                'comment_content'      => $data['comment'],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'comment_type'         => '',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'comment_type'         => 'comment',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'comment_parent'       => '0',
</span><span class="cx" style="display: block; padding: 0 10px">                                'user_ID'              => $user->ID,
</span><span class="cx" style="display: block; padding: 0 10px">                                'user_id'              => $user->ID,
</span></span></pre>
</div>
</div>

</body>
</html>