diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/comment.php --- a/wp/wp-admin/includes/comment.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/comment.php Tue Dec 15 13:49:49 2020 +0100 @@ -21,8 +21,7 @@ * @param string $comment_author Author of the comment. * @param string $comment_date Date of the comment. * @param string $timezone Timezone. Accepts 'blog' or 'gmt'. Default 'blog'. - * - * @return mixed Comment post ID on success. + * @return string|null Comment post ID on success. */ function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) { global $wpdb; @@ -46,6 +45,10 @@ * Update a comment with values provided in $_POST. * * @since 2.0.0 + * @since 5.5.0 A return value was added. + * + * @return int|WP_Error The value 1 if the comment was updated, 0 if not updated. + * A WP_Error object on failure. */ function edit_comment() { if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) { @@ -79,20 +82,21 @@ } if ( ! empty( $_POST['edit_date'] ) ) { - $aa = $_POST['aa']; - $mm = $_POST['mm']; - $jj = $_POST['jj']; - $hh = $_POST['hh']; - $mn = $_POST['mn']; - $ss = $_POST['ss']; - $jj = ( $jj > 31 ) ? 31 : $jj; - $hh = ( $hh > 23 ) ? $hh - 24 : $hh; - $mn = ( $mn > 59 ) ? $mn - 60 : $mn; - $ss = ( $ss > 59 ) ? $ss - 60 : $ss; + $aa = $_POST['aa']; + $mm = $_POST['mm']; + $jj = $_POST['jj']; + $hh = $_POST['hh']; + $mn = $_POST['mn']; + $ss = $_POST['ss']; + $jj = ( $jj > 31 ) ? 31 : $jj; + $hh = ( $hh > 23 ) ? $hh - 24 : $hh; + $mn = ( $mn > 59 ) ? $mn - 60 : $mn; + $ss = ( $ss > 59 ) ? $ss - 60 : $ss; + $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; } - wp_update_comment( $_POST ); + return wp_update_comment( $_POST, true ); } /** @@ -104,7 +108,8 @@ * @return WP_Comment|false Comment if found. False on failure. */ function get_comment_to_edit( $id ) { - if ( ! $comment = get_comment( $id ) ) { + $comment = get_comment( $id ); + if ( ! $comment ) { return false; } @@ -117,7 +122,7 @@ * * @since 2.0.0 * - * @param string $comment->comment_content Comment content. + * @param string $comment_content Comment content. */ $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); @@ -164,7 +169,7 @@ $pending_keyed = array(); - // Default to zero pending for all posts in request + // Default to zero pending for all posts in request. foreach ( $post_id_array as $id ) { $pending_keyed[ $id ] = 0; } @@ -179,12 +184,12 @@ } /** - * Add avatars to relevant places in admin, or try to. + * Adds avatars to relevant places in admin. * * @since 2.5.0 * * @param string $name User name. - * @return string Avatar with Admin name. + * @return string Avatar with the user name. */ function floated_admin_avatar( $name ) { $avatar = get_avatar( get_comment(), 32, 'mystery' ); @@ -195,7 +200,7 @@ * @since 2.7.0 */ function enqueue_comment_hotkeys_js() { - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { + if ( 'true' === get_user_option( 'comment_shortcuts' ) ) { wp_enqueue_script( 'jquery-table-hotkeys' ); } } @@ -207,6 +212,6 @@ */ function comment_footer_die( $msg ) { echo "

$msg

"; - include( ABSPATH . 'wp-admin/admin-footer.php' ); + require_once ABSPATH . 'wp-admin/admin-footer.php'; die; }