Make WordPress Core


Ignore:
Timestamp:
07/19/2022 04:17:56 PM (20 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename $comment_post_ID and $comment_author_IP variables in various files.

This fixes two WPCS warnings:

  • Variable "$comment_post_ID" is not in valid snake_case format
  • Variable "$comment_author_IP" is not in valid snake_case format

While matching the database fields of the same name, these variables did not follow the WordPress coding standards, and are now renamed to address that.

Note: The name change only affects internal variables and parameters for a few actions receiving a comment post ID:

  • edit_comment
  • comment_id_not_found
  • comment_closed
  • comment_on_trash
  • comment_on_draft
  • comment_on_password_protected
  • pre_comment_on_post

The change does not affect parameters for functions receiving an array of comment data:

  • wp_insert_comment()
  • wp_new_comment()
  • wp_update_comment()
  • wp_handle_comment_submission()

The associated array keys still match the database fields: comment_post_ID and comment_author_IP.

Follow-up to [1706], [2894], [8720], [28427], [28437], [28457], [34799], [53720],

See #55647, #56244.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r53455 r53723  
    12781278    check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
    12791279
    1280     $comment_post_ID = (int) $_POST['comment_post_ID'];
    1281     $post            = get_post( $comment_post_ID );
     1280    $comment_post_id = (int) $_POST['comment_post_ID'];
     1281    $post            = get_post( $comment_post_id );
    12821282
    12831283    if ( ! $post ) {
     
    12851285    }
    12861286
    1287     if ( ! current_user_can( 'edit_post', $comment_post_ID ) ) {
     1287    if ( ! current_user_can( 'edit_post', $comment_post_id ) ) {
    12881288        wp_die( -1 );
    12891289    }
     
    13321332
    13331333    $comment_auto_approved = false;
    1334     $commentdata           = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID' );
     1334
     1335    $commentdata = array(
     1336        'comment_post_ID' => $comment_post_id,
     1337    );
     1338
     1339    $commentdata += compact(
     1340        'comment_author',
     1341        'comment_author_email',
     1342        'comment_author_url',
     1343        'comment_content',
     1344        'comment_type',
     1345        'comment_parent',
     1346        'user_ID'
     1347    );
    13351348
    13361349    // Automatically approve parent comment.
     
    13381351        $parent = get_comment( $comment_parent );
    13391352
    1340         if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_ID ) {
     1353        if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_id ) {
    13411354            if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
    13421355                wp_die( -1 );
Note: See TracChangeset for help on using the changeset viewer.