[wp-trac] [WordPress Trac] #56261: Normalize comment function parameters with mixed case names

WordPress Trac noreply at wordpress.org
Wed Jul 20 16:30:32 UTC 2022


#56261: Normalize comment function parameters with mixed case names
------------------------------------+--------------------
 Reporter:  SergeyBiryukov          |      Owner:  (none)
     Type:  enhancement             |     Status:  new
 Priority:  normal                  |  Milestone:  6.1
Component:  Comments                |    Version:
 Severity:  normal                  |   Keywords:
  Focuses:  docs, coding-standards  |
------------------------------------+--------------------
 Background: #56244

 As of WordPress 2.9, core normalizes the `user_ID` parameter to `user_id`
 when passing data to comment functions, see [12267], [12300], and [28915].

 We should consider normalizing other parameters in the same way as it was
 done for `user_ID` → `user_id`:

 * `comment_ID` → `comment_id`
 * `comment_post_ID` → `comment_post_id`
 * `comment_author_IP` → `comment_author_ip`

 Then any combination of these parameters would work regardless of the
 case.

 This would allow extenders to name variables in accordance with the
 WordPress coding standards:
 * `$comment_id`
 * `$comment_post_id`
 * `$comment_author_ip`
 and use them subsequently in a `compact()` call without having to worry
 about a case mismatch.

 This would also allow us to revert some of `compact()` rearrangements made
 in [53719] and [53723]:
 {{{
 $compacted = array(
         'comment_post_ID'   => $comment_post_id,
         'comment_author_IP' => $comment_author_ip,
 );

 $compacted += compact(
         'comment_author',
         'comment_author_email',
         'comment_author_url',
         ...
         'user_id'
 );
 }}}
 which could then be:
 {{{
 $compacted = compact(
         'comment_post_id',
         'comment_author',
         'comment_author_email',
         'comment_author_url',
         'comment_author_ip',
         ...
         'user_id'
 );
 }}}

 The list of functions this may affect:
 * `wp_insert_comment()`
 * `wp_new_comment()`
 * `wp_update_comment()`
 * `wp_filter_comment()`
 * `wp_handle_comment_submission()`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56261>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list