Make WordPress Core


Ignore:
Timestamp:
02/12/2023 06:06:33 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename $comment_ID variable to $comment_id in various files.

This resolves 80+ WPCS warnings in core:

Variable "$comment_ID" is not in valid snake_case format

While matching the database field of the same name, the $comment_ID variable did not follow the WordPress coding standards, and is now renamed to address that.

This affects:

  • Function parameters in:
    • get_comment_author()
    • comment_author()
    • get_comment_author_email()
    • comment_author_email()
    • get_comment_author_link()
    • comment_author_link()
    • get_comment_author_IP()
    • comment_author_IP()
    • get_comment_author_rl()
    • comment_author_url()
    • get_comment_date()
    • comment_date()
    • get_comment_excerpt()
    • comment_excerpt()
    • get_comment_text()
    • comment_text()
    • get_comment_time()
    • comment_time()
    • get_comment_type()
    • get_page_of_comment()
    • wp_new_comment_notify_moderator()
    • wp_new_comment_notify_postauthor()
    • get_commentdata()
  • Internal variables in:
    • get_comment_ID()
    • wp_new_comment()
    • wp_xmlrpc_server::wp_deleteComment()
    • wp_xmlrpc_server::wp_editComment()
    • wp_xmlrpc_server::wp_newComment()
    • wp_xmlrpc_server::pingback_ping()
  • Hook parameters in:
    • get_comment_author
    • comment_author
    • get_comment_author_email
    • author_email
    • get_comment_author_link
    • get_comment_author_IP
    • get_comment_author_url
    • comment_url
    • get_comment_excerpt
    • comment_excerpt
    • get_comment_ID
    • get_comment_type
    • get_page_of_comment
    • comment_{$new_status}_{$comment->comment_type}
    • comment_post
    • notify_moderator
    • notify_post_author
    • commentrss2_item
    • xmlrpc_call_success_wp_deleteComment
    • xmlrpc_call_success_wp_editComment
    • xmlrpc_call_success_wp_newComment
    • pingback_post

Note: The name change only affects variable names and DocBlocks.

The change does not affect:

  • comment_ID as the $orderby value in WP_Comment_Query::__construct()
  • comment_ID as the $orderby value in WP_Comment::get_children()
  • comment_ID as part of $commentarr parameter in wp_update_comment()

The associated array keys still match the database field.

Follow-up to [53723].

Props krunal265, costdev, SergeyBiryukov.
Fixes #57671. See #56791.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r54877 r55308  
    37213721        $username   = $args[1];
    37223722        $password   = $args[2];
    3723         $comment_ID = (int) $args[3];
     3723        $comment_id = (int) $args[3];
    37243724
    37253725        $user = $this->login( $username, $password );
     
    37283728        }
    37293729
    3730         if ( ! get_comment( $comment_ID ) ) {
     3730        if ( ! get_comment( $comment_id ) ) {
    37313731            return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
    37323732        }
    37333733
    3734         if ( ! current_user_can( 'edit_comment', $comment_ID ) ) {
     3734        if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
    37353735            return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) );
    37363736        }
     
    37393739        do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this );
    37403740
    3741         $status = wp_delete_comment( $comment_ID );
     3741        $status = wp_delete_comment( $comment_id );
    37423742
    37433743        if ( $status ) {
     
    37473747             * @since 3.4.0
    37483748             *
    3749              * @param int   $comment_ID ID of the deleted comment.
     3749             * @param int   $comment_id ID of the deleted comment.
    37503750             * @param array $args       An array of arguments to delete the comment.
    37513751             */
    3752             do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     3752            do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    37533753        }
    37543754
     
    37883788        $username       = $args[1];
    37893789        $password       = $args[2];
    3790         $comment_ID     = (int) $args[3];
     3790        $comment_id     = (int) $args[3];
    37913791        $content_struct = $args[4];
    37923792
     
    37963796        }
    37973797
    3798         if ( ! get_comment( $comment_ID ) ) {
     3798        if ( ! get_comment( $comment_id ) ) {
    37993799            return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
    38003800        }
    38013801
    3802         if ( ! current_user_can( 'edit_comment', $comment_ID ) ) {
     3802        if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
    38033803            return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
    38043804        }
     
    38073807        do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
    38083808        $comment = array(
    3809             'comment_ID' => $comment_ID,
     3809            'comment_ID' => $comment_id,
    38103810        );
    38113811
     
    38593859         * @since 3.4.0
    38603860         *
    3861          * @param int   $comment_ID ID of the updated comment.
     3861         * @param int   $comment_id ID of the updated comment.
    38623862         * @param array $args       An array of arguments to update the comment.
    38633863         */
    3864         do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     3864        do_action( 'xmlrpc_call_success_wp_editComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    38653865
    38663866        return true;
     
    40004000        do_action( 'xmlrpc_call', 'wp.newComment', $args, $this );
    40014001
    4002         $comment_ID = wp_new_comment( $comment, true );
    4003         if ( is_wp_error( $comment_ID ) ) {
    4004             return new IXR_Error( 403, $comment_ID->get_error_message() );
    4005         }
    4006 
    4007         if ( ! $comment_ID ) {
     4002        $comment_id = wp_new_comment( $comment, true );
     4003        if ( is_wp_error( $comment_id ) ) {
     4004            return new IXR_Error( 403, $comment_id->get_error_message() );
     4005        }
     4006
     4007        if ( ! $comment_id ) {
    40084008            return new IXR_Error( 403, __( 'Something went wrong.' ) );
    40094009        }
     
    40144014         * @since 3.4.0
    40154015         *
    4016          * @param int   $comment_ID ID of the new comment.
     4016         * @param int   $comment_id ID of the new comment.
    40174017         * @param array $args       An array of new comment arguments.
    40184018         */
    4019         do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    4020 
    4021         return $comment_ID;
     4019        do_action( 'xmlrpc_call_success_wp_newComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     4020
     4021        return $comment_id;
    40224022    }
    40234023
     
    70417041        );
    70427042
    7043         $comment_ID = wp_new_comment( $commentdata );
    7044 
    7045         if ( is_wp_error( $comment_ID ) ) {
    7046             return $this->pingback_error( 0, $comment_ID->get_error_message() );
     7043        $comment_id = wp_new_comment( $commentdata );
     7044
     7045        if ( is_wp_error( $comment_id ) ) {
     7046            return $this->pingback_error( 0, $comment_id->get_error_message() );
    70477047        }
    70487048
     
    70527052         * @since 0.71
    70537053         *
    7054          * @param int $comment_ID Comment ID.
     7054         * @param int $comment_id Comment ID.
    70557055         */
    7056         do_action( 'pingback_post', $comment_ID );
     7056        do_action( 'pingback_post', $comment_id );
    70577057
    70587058        /* translators: 1: URL of the page linked from, 2: URL of the page linked to. */
Note: See TracChangeset for help on using the changeset viewer.