Ticket #49236: 49236.2.patch
File 49236.2.patch, 10.3 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php index ea33d9d792..180335a005 100644
function wp_ajax_replyto_comment( $action ) { 1283 1283 $comment_author_email = wp_slash( $user->user_email ); 1284 1284 $comment_author_url = wp_slash( $user->user_url ); 1285 1285 $comment_content = trim( $_POST['content'] ); 1286 $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : ' ';1286 $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : 'comment'; 1287 1287 1288 1288 if ( current_user_can( 'unfiltered_html' ) ) { 1289 1289 if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) { -
src/wp-admin/includes/schema.php
diff --git src/wp-admin/includes/schema.php src/wp-admin/includes/schema.php index bb993f2617..b191cd6476 100644
CREATE TABLE $wpdb->comments ( 111 111 comment_karma int(11) NOT NULL default '0', 112 112 comment_approved varchar(20) NOT NULL default '1', 113 113 comment_agent varchar(255) NOT NULL default '', 114 comment_type varchar(20) NOT NULL default ' ',114 comment_type varchar(20) NOT NULL default 'comment', 115 115 comment_parent bigint(20) unsigned NOT NULL default '0', 116 116 user_id bigint(20) unsigned NOT NULL default '0', 117 117 PRIMARY KEY (comment_ID), -
src/wp-admin/includes/upgrade.php
diff --git src/wp-admin/includes/upgrade.php src/wp-admin/includes/upgrade.php index 26614c9634..c38cd6d4f8 100644
Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' 283 283 'comment_date' => $now, 284 284 'comment_date_gmt' => $now_gmt, 285 285 'comment_content' => $first_comment, 286 'comment_type' => 'comment', 286 287 ) 287 288 ); 288 289 … … function upgrade_all() { 834 835 upgrade_530(); 835 836 } 836 837 838 if ( $wp_current_db_version < 47426 ) { 839 wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_types_batch' ); 840 } 841 837 842 maybe_disable_link_manager(); 838 843 839 844 maybe_disable_automattic_widgets(); -
src/wp-content/themes/twentyten/functions.php
diff --git src/wp-content/themes/twentyten/functions.php src/wp-content/themes/twentyten/functions.php index 96629d1074..6c092f1074 100644
if ( ! function_exists( 'twentyten_comment' ) ) : 418 418 $GLOBALS['comment'] = $comment; 419 419 switch ( $comment->comment_type ) : 420 420 case '': 421 case 'comment': 421 422 ?> 422 423 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 423 424 <div id="comment-<?php comment_ID(); ?>"> -
src/wp-includes/class-wp-comment-query.php
diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php index 8d788a3ec3..4b9d80e3e3 100644
class WP_Comment_Query { 741 741 742 742 case 'comment': 743 743 case 'comments': 744 $comment_types[ $operator ][] = "' '";744 $comment_types[ $operator ][] = "'comment'"; 745 745 break; 746 746 747 747 case 'pings': -
src/wp-includes/class-wp-comment.php
diff --git src/wp-includes/class-wp-comment.php src/wp-includes/class-wp-comment.php index 70d7db2bd8..9b3b57e206 100644
final class WP_Comment { 116 116 * @since 4.4.0 117 117 * @var string 118 118 */ 119 public $comment_type = ' ';119 public $comment_type = 'comment'; 120 120 121 121 /** 122 122 * Parent comment ID. -
src/wp-includes/comment.php
diff --git src/wp-includes/comment.php src/wp-includes/comment.php index 15cb44bcc3..768bc53c76 100644
function wp_insert_comment( $commentdata ) { 1901 1901 $comment_karma = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma']; 1902 1902 $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved']; 1903 1903 $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent']; 1904 $comment_type = ! isset( $data['comment_type'] ) ? ' ' : $data['comment_type'];1904 $comment_type = ! isset( $data['comment_type'] ) ? 'comment' : $data['comment_type']; 1905 1905 $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent']; 1906 1906 1907 1907 $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id']; … … function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment 2057 2057 * @type string $comment_author_email The comment author email address. 2058 2058 * @type string $comment_author_url The comment author URL. 2059 2059 * @type string $comment_content The content of the comment. 2060 * @type string $comment_type The name of the comment type. 2060 2061 * @type string $comment_date The date the comment was submitted. Default is the current time. 2061 2062 * @type string $comment_date_gmt The date the comment was submitted in the GMT timezone. 2062 2063 * Default is `$comment_date` in the GMT timezone. … … function wp_new_comment( $commentdata, $avoid_die = false ) { 2122 2123 $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 ); 2123 2124 } 2124 2125 2126 if ( empty( $commentdata['comment_type'] ) ) { 2127 $commentdata['comment_type'] = 'comment'; 2128 } 2129 2125 2130 $commentdata = wp_filter_comment( $commentdata ); 2126 2131 2127 2132 $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die ); … … function wp_handle_comment_submission( $comment_data ) { 3348 3353 } 3349 3354 } 3350 3355 3351 $comment_type = ' ';3356 $comment_type = 'comment'; 3352 3357 3353 3358 if ( get_option( 'require_name_email' ) && ! $user->exists() ) { 3354 3359 if ( '' == $comment_author_email || '' == $comment_author ) { … … function wp_comments_personal_data_eraser( $email_address, $page = 1 ) { 3636 3641 function wp_cache_set_comments_last_changed() { 3637 3642 wp_cache_set( 'last_changed', microtime(), 'comment' ); 3638 3643 } 3644 3645 /** 3646 * Updates the comment type of a batch of comments. 3647 * 3648 * @since 5.5.0 3649 * 3650 * @global wpdb $wpdb WordPress database abstraction object. 3651 */ 3652 function _wp_batch_update_comment_types() { 3653 global $wpdb; 3654 3655 $lock_name = 'update_comment_types.lock'; 3656 3657 // Try to lock. 3658 $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) ); 3659 3660 if ( ! $lock_result ) { 3661 $lock_result = get_option( $lock_name ); 3662 3663 // Bail if we were unable to create a lock, or if the existing lock is still valid. 3664 if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) { 3665 wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_update_comment_types_batch' ); 3666 return; 3667 } 3668 } 3669 3670 // Update the lock, as by this point we've definitely got a lock, just need to fire the actions. 3671 update_option( $lock_name, time() ); 3672 3673 // Check if there's still empty comment types. 3674 $empty_comment_types = $wpdb->get_var( 3675 "SELECT comment_ID FROM $wpdb->comments 3676 WHERE comment_type = '' 3677 LIMIT 1" 3678 ); 3679 3680 // No empty comment types, we're done here. 3681 if ( ! $empty_comment_types ) { 3682 update_option( 'finished_updating_comments_type', true ); 3683 delete_option( $lock_name ); 3684 return; 3685 } 3686 3687 // Empty comment types found? We'll need to run this script again. 3688 wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_update_comment_types_batch' ); 3689 3690 // Update the `comment_type` field value to be `comment` for the next 100 rows about comments. 3691 $wpdb->query( 3692 "UPDATE {$wpdb->comments} 3693 SET comment_type = 'comment' 3694 WHERE comment_type = '' 3695 ORDER BY comment_ID DESC 3696 LIMIT 100" 3697 ); 3698 3699 delete_option( $lock_name ); 3700 } 3701 3702 /** 3703 * In order to avoid the _wp_batch_update_comment_types() job being accidentally removed, 3704 * check that it's still scheduled while we haven't finished updating comment types. 3705 * 3706 * @ignore 3707 * @since 5.5.0 3708 */ 3709 function _wp_check_for_scheduled_update_comment_types() { 3710 if ( ! get_option( 'finished_updating_comments_type' ) && ! wp_next_scheduled( 'wp_update_comment_types_batch' ) ) { 3711 wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_update_comment_types_batch' ); 3712 } 3713 } -
src/wp-includes/default-filters.php
diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php index 9a46d7e2f7..9a8636760c 100644
add_action( 'rest_api_init', 'register_initial_settings', 10 ); 450 450 add_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); 451 451 add_action( 'parse_request', 'rest_api_loaded' ); 452 452 453 // Comments comment type updates. 454 add_action( 'admin_init', '_wp_check_for_scheduled_update_comment_types' ); 455 add_action( 'wp_update_comment_types_batch', '_wp_batch_update_comment_types' ); 456 453 457 /** 454 458 * Filters formerly mixed into wp-includes. 455 459 */ -
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index 8d241d7c63..f12082c3c0 100644
class WP_REST_Comments_Controller extends WP_REST_Controller { 585 585 return $prepared_comment; 586 586 } 587 587 588 $prepared_comment['comment_type'] = ' ';588 $prepared_comment['comment_type'] = 'comment'; 589 589 590 590 /* 591 591 * Do not allow a comment to be created with missing or empty -
src/wp-includes/version.php
diff --git src/wp-includes/version.php src/wp-includes/version.php index 3cb65cb0cd..344c43186d 100644
$wp_version = '5.5-alpha-47426-src'; 20 20 * 21 21 * @global int $wp_db_version 22 22 */ 23 $wp_db_version = 47 018;23 $wp_db_version = 47426; 24 24 25 25 /** 26 26 * Holds the TinyMCE version. -
tests/phpunit/tests/comment-submission.php
diff --git tests/phpunit/tests/comment-submission.php tests/phpunit/tests/comment-submission.php index 70d9bb1185..6a5b845bb0 100644
class Tests_Comment_Submission extends WP_UnitTestCase { 742 742 'comment_author_email' => $user->user_email, 743 743 'comment_author_url' => $user->user_url, 744 744 'comment_content' => $data['comment'], 745 'comment_type' => ' ',745 'comment_type' => 'comment', 746 746 'comment_parent' => '0', 747 747 'user_ID' => $user->ID, 748 748 'user_id' => $user->ID,