Changeset 47597
- Timestamp:
- 04/17/2020 07:33:52 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r47550 r47597 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' ) ) { -
trunk/src/wp-admin/includes/schema.php
r47550 r47597 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', -
trunk/src/wp-admin/includes/upgrade.php
r47550 r47597 284 284 'comment_date_gmt' => $now_gmt, 285 285 'comment_content' => $first_comment, 286 'comment_type' => 'comment', 286 287 ) 287 288 ); … … 835 836 } 836 837 838 if ( $wp_current_db_version < 47597 ) { 839 upgrade_550(); 840 } 841 837 842 maybe_disable_link_manager(); 838 843 … … 2156 2161 2157 2162 /** 2163 * Executes changes made in WordPress 5.5.0. 2164 * 2165 * @ignore 2166 * @since 5.5.0 2167 */ 2168 function upgrade_550() { 2169 update_option( 'finished_updating_comment_type', 0 ); 2170 wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' ); 2171 } 2172 2173 /** 2158 2174 * Executes network-level upgrade routines. 2159 2175 * -
trunk/src/wp-content/themes/twentyten/functions.php
r47122 r47597 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(); ?>"> -
trunk/src/wp-includes/class-wp-comment-query.php
r47550 r47597 742 742 case 'comment': 743 743 case 'comments': 744 $comment_types[ $operator ][] = "' '";744 $comment_types[ $operator ][] = "'comment'"; 745 745 break; 746 746 -
trunk/src/wp-includes/class-wp-comment.php
r47550 r47597 115 115 * 116 116 * @since 4.4.0 117 * @var string 118 */ 119 public $comment_type = ''; 117 * @since 5.5.0 Default value changed to `comment`. 118 * @var string 119 */ 120 public $comment_type = 'comment'; 120 121 121 122 /** -
trunk/src/wp-includes/comment.php
r47550 r47597 1854 1854 * 1855 1855 * @since 2.0.0 1856 * @since 4.4.0 Introduced `$comment_meta` argument. 1856 * @since 4.4.0 Introduced the `$comment_meta` argument. 1857 * @since 5.5.0 Default value for `$comment_type` argument changed to `comment`. 1857 1858 * 1858 1859 * @global wpdb $wpdb WordPress database abstraction object. … … 1878 1879 * @type int $comment_post_ID ID of the post that relates to the comment, if any. 1879 1880 * Default 0. 1880 * @type string $comment_type Comment type. Default empty.1881 * @type string $comment_type Comment type. Default 'comment'. 1881 1882 * @type array $comment_meta Optional. Array of key/value pairs to be stored in commentmeta for the 1882 1883 * new comment. … … 1902 1903 $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved']; 1903 1904 $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent']; 1904 $comment_type = ! isset( $data['comment_type'] ) ? ' ' : $data['comment_type'];1905 $comment_type = ! isset( $data['comment_type'] ) ? 'comment' : $data['comment_type']; 1905 1906 $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent']; 1906 1907 … … 2044 2045 * 2045 2046 * @since 1.5.0 2046 * @since 4.3.0 'comment_agent' and 'comment_author_IP' can be set via `$commentdata`.2047 * @since 4.3.0 Introduced the `comment_agent` and `comment_author_IP` arguments. 2047 2048 * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function to 2048 2049 * return a WP_Error object instead of dying. 2050 * @since 5.5.0 Introduced the `comment_type` argument. 2049 2051 * 2050 2052 * @see wp_insert_comment() … … 2061 2063 * @type string $comment_date_gmt The date the comment was submitted in the GMT timezone. 2062 2064 * Default is `$comment_date` in the GMT timezone. 2065 * @type string $comment_type Comment type. Default 'comment'. 2063 2066 * @type int $comment_parent The ID of this comment's parent, if any. Default 0. 2064 2067 * @type int $comment_post_ID The ID of the post that relates to the comment. … … 2121 2124 if ( empty( $commentdata['comment_date_gmt'] ) ) { 2122 2125 $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 ); 2126 } 2127 2128 if ( empty( $commentdata['comment_type'] ) ) { 2129 $commentdata['comment_type'] = 'comment'; 2123 2130 } 2124 2131 … … 3349 3356 } 3350 3357 3351 $comment_type = ' ';3358 $comment_type = 'comment'; 3352 3359 3353 3360 if ( get_option( 'require_name_email' ) && ! $user->exists() ) { … … 3637 3644 wp_cache_set( 'last_changed', microtime(), 'comment' ); 3638 3645 } 3646 3647 /** 3648 * Updates the comment type for a batch of comments. 3649 * 3650 * @since 5.5.0 3651 * 3652 * @global wpdb $wpdb WordPress database abstraction object. 3653 */ 3654 function _wp_batch_update_comment_type() { 3655 global $wpdb; 3656 3657 $lock_name = 'update_comment_type.lock'; 3658 3659 // Try to lock. 3660 $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) ); 3661 3662 if ( ! $lock_result ) { 3663 $lock_result = get_option( $lock_name ); 3664 3665 // Bail if we were unable to create a lock, or if the existing lock is still valid. 3666 if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) { 3667 wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' ); 3668 return; 3669 } 3670 } 3671 3672 // Update the lock, as by this point we've definitely got a lock, just need to fire the actions. 3673 update_option( $lock_name, time() ); 3674 3675 // Check if there's still an empty comment type. 3676 $empty_comment_type = $wpdb->get_var( 3677 "SELECT comment_ID FROM $wpdb->comments 3678 WHERE comment_type = '' 3679 LIMIT 1" 3680 ); 3681 3682 // No empty comment type, we're done here. 3683 if ( ! $empty_comment_type ) { 3684 update_option( 'finished_updating_comment_type', true ); 3685 delete_option( $lock_name ); 3686 return; 3687 } 3688 3689 // Empty comment type found? We'll need to run this script again. 3690 wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' ); 3691 3692 // Update the `comment_type` field value to be `comment` for the next 100 rows of comments. 3693 $wpdb->query( 3694 "UPDATE {$wpdb->comments} 3695 SET comment_type = 'comment' 3696 WHERE comment_type = '' 3697 ORDER BY comment_ID DESC 3698 LIMIT 100" 3699 ); 3700 3701 delete_option( $lock_name ); 3702 } 3703 3704 /** 3705 * In order to avoid the _wp_batch_update_comment_type() job being accidentally removed, 3706 * check that it's still scheduled while we haven't finished updating comment types. 3707 * 3708 * @ignore 3709 * @since 5.5.0 3710 */ 3711 function _wp_check_for_scheduled_update_comment_type() { 3712 if ( ! get_option( 'finished_updating_comment_type' ) && ! wp_next_scheduled( 'wp_update_comment_type_batch' ) ) { 3713 wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_update_comment_type_batch' ); 3714 } 3715 } -
trunk/src/wp-includes/default-filters.php
r47554 r47597 439 439 add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' ); 440 440 441 // Comment type updates. 442 add_action( 'admin_init', '_wp_check_for_scheduled_update_comment_type' ); 443 add_action( 'wp_update_comment_type_batch', '_wp_batch_update_comment_type' ); 444 441 445 // Email notifications. 442 446 add_action( 'comment_post', 'wp_new_comment_notify_moderator' ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r47391 r47597 586 586 } 587 587 588 $prepared_comment['comment_type'] = ' ';588 $prepared_comment['comment_type'] = 'comment'; 589 589 590 590 /* -
trunk/src/wp-includes/version.php
r47426 r47597 21 21 * @global int $wp_db_version 22 22 */ 23 $wp_db_version = 47 018;23 $wp_db_version = 47597; 24 24 25 25 /** -
trunk/tests/phpunit/tests/comment-submission.php
r47122 r47597 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,
Note: See TracChangeset
for help on using the changeset viewer.