Opened 2 years ago
Closed 2 years ago
#56754 closed defect (bug) (fixed)
Use consistent, coding standard compliant naming for category ID variables
Reported by: | hilayt24 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
In "app/public/wp-admin/includes/taxonomy.php" while scanning I found the following errors and warnings.
189 | ERROR | Variable "$cat_ID" is not in valid snake_case format, try "$cat_i_d" 191 | ERROR | Variable "$cat_ID" is not in valid snake_case format, try "$cat_i_d" 191 | WARNING | Found: ==. Use strict comparisons (=== or !==). 196 | ERROR | Variable "$cat_ID" is not in valid snake_case format, try "$cat_i_d"
WordPress Version : 6.0.2
PHPCS Standard : WordPress-Core
Attachments (2)
Change History (18)
#1
@
2 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 6.2
#2
@
2 years ago
- Summary changed from While scanning through the files for the standards I found errors and warnings. to Use consistent, coding standard compliant naming for category ID variables
Related: [52958].
#3
@
2 years ago
Thanks everyone who added patch.
Patch: https://core.trac.wordpress.org/attachment/ticket/56754/56754.diff
I am not sure if we need the empty check or not.
Also !empty
should be ! empty
to maintain the coding standard if I am not wrong.
Patch: https://core.trac.wordpress.org/attachment/ticket/56754/%2356754.patch
Looks straight forward to me and good.
#4
@
2 years ago
Hi, I have searched $cat_ID throughout the full project in my local setup and I have found this in 3 different files, and total 13 occurrences.
Here are the file locations:
- wordpress-develop/src/wp-admin/includes/taxonomy.php
- wordpress-develop/src/wp-includes/deprecated.php
- wordpress-develop/src/wp-includes/taxonomy.php
I think it would be better if we could fix in all 3 files.
Screenshot: https://d.pr/i/gf7c6l
This ticket was mentioned in PR #3961 on WordPress/wordpress-develop by @robinwpdeveloper.
2 years ago
#6
Trac ticket: https://core.trac.wordpress.org/ticket/56754
#7
follow-up:
↓ 11
@
2 years ago
Hi @robinwpdeveloper, thanks for the ping!
I agree that #56754.patch is more straightforward, as the other patch contains a condition and unrelated inline comments.
Thanks for the PR which verified no tests were broken by the changes!
I've left a review noting that we can't change function parameter casing due to named parameters in PHP 8, which are case-sensitive.
Can you update the PR to remove the changes in src/wp-includes/deprecated.php
and src/wp-includes/taxonomy.php
?
Other than that, I think the PR is good to go.
@robinwpdeveloper commented on PR #3961:
2 years ago
#8
Thanks @costdev
Changes are made as per feedback.
#9
@
2 years ago
Changes are made as per requested.
I think we are good to go now.
#11
in reply to:
↑ 7
@
2 years ago
Replying to costdev:
I've left a review noting that we can't change function parameter casing due to named parameters in PHP 8, which are case-sensitive.
That's correct, but as noted in the PHP 8.0 dev note, WordPress does not support named parameters at this time:
Using named parameters when calling WordPress functions and class methods is explicitly not supported and highly discouraged until this audit can be completed, as during the audit, parameter names are subject to change without notice. When this audit has been completed, it will be announced in a future developer note.
See tickets #51553, #55327, #55650, #56788 for continued work on this.
So I think we can include those parameter renamings here too.
@SergeyBiryukov commented on PR #3961:
2 years ago
#13
Thanks for the PR! Merged in r55190.
I fixed the PHPCS errors and checked the changes in the site also.