#57671 closed defect (bug) (fixed)
Coding Standards: To maintain a valid snake case format, need to rename $comment_ID variable
Reported by: | krunal265 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | 6.2 |
Component: | Comments | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
For the below files:
wp-admin/comment.php wp-includes/comment-template.php wp-includes/comment.php
Attachments (1)
Change History (9)
#1
@
20 months ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
#2
@
20 months ago
- Component changed from General to Comments
- Keywords has-patch added; needs-patch removed
- Milestone set to 6.2
- Resolution duplicate deleted
- Severity changed from major to normal
- Status changed from closed to reopened
- Type changed from enhancement to defect (bug)
Hi there, thanks for the ticket!
Yeah, I've started looking into this as well after [55284] / #52322.
Reopening, as this can be done separately from #56261. That ticket is mostly focused on the comment_ID
value of the comment data array in functions like wp_new_comment()
, wp_update_comment()
, or wp_filter_comment()
, where plugins may expect both comment_id
and comment_ID
values to exist in the array.
This ticket can be focused strictly on renaming the $comment_ID
variable to match core coding standards. This will affect function parameters, internal variables, and update hook DocBlocks to encourage better practices.
Aside from using PHP 8.0+ named parameters, which WordPress does not explicitly support at this time, backward compatibility should not be affected, so I think this can be done in 6.2 as part of other coding standards fixes.
57671.diff resolves all of these 83 WPCS warnings in core:
Variable "$comment_ID" is not in valid snake_case format, try "$comment_i_d"
#4
@
20 months ago
After a visual inspection, and since we aren't currently avoiding renaming function parameters, the patch looks good to me. PHPUnit tests pass and such too.
#6
@
20 months ago
- Keywords add-to-field-guide added
Should get a mention in the Misc Dev Note, as there might be extenders out there expecting $comment_ID
"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."
The database fields are still comment_ID
Hi @krunal265, I believe we're already tracking this enhancement in #56261