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/deprecated.php

    r55258 r55308  
    12261226
    12271227/**
    1228  * Retrieve an array of comment data about comment $comment_ID.
     1228 * Retrieve an array of comment data about comment $comment_id.
    12291229 *
    12301230 * @since 0.71
     
    12321232 * @see get_comment()
    12331233 *
    1234  * @param int $comment_ID The ID of the comment
     1234 * @param int $comment_id The ID of the comment
    12351235 * @param int $no_cache Whether to use the cache (cast to bool)
    12361236 * @param bool $include_unapproved Whether to include unapproved comments
    12371237 * @return array The comment data
    12381238 */
    1239 function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
     1239function get_commentdata( $comment_id, $no_cache = 0, $include_unapproved = false ) {
    12401240    _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' );
    1241     return get_comment($comment_ID, ARRAY_A);
     1241    return get_comment($comment_id, ARRAY_A);
    12421242}
    12431243
Note: See TracChangeset for help on using the changeset viewer.