#58878 closed defect (bug) (invalid)
Replace all instances of ctype_digit() with is_numeric()
Reported by: | rajinsharwar | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch |
Focuses: | Cc: |
Description
As per [PHP 8.1 Deprecations](https://wiki.php.net/rfc/deprecations_php_8_1), they have deprecated ctype_*() function family to accept int parameters, especially the ctype_digit() function. So, proposing to use the is_numeric() function instead.
Attachments (1)
Change History (7)
This ticket was mentioned in PR #4889 on WordPress/wordpress-develop by @rajinsharwar.
14 months ago
#1
- Keywords has-patch added
#2
@
14 months ago
ctype_digit
is /d+/
match, while is_numeric
function is /[\d.]/
, so the two functions are not identical.
I think the correct approach is to cast the variable to a string e.g ctype_digit((string) $var)
.
#4
@
14 months ago
- Milestone 6.4 deleted
- Resolution set to invalid
- Status changed from new to closed
Hello and thanks for the ticket, however ID3 is an external library, so this ticket should therefore be reported upstream on https://github.com/JamesHeinrich/getID3.
#5
@
14 months ago
- Milestone set to 6.4
Hi @rajinsharwar, welcome back to Trac and thanks for opening this ticket.
A few thoughts:
- As @ayeshrajans says,
ctype_digit()
andis_numeric()
have different behaviour. - None of the patched uses of
ctype_digit()
in 58878.diff are susceptible to the deprecation notice.- This only runs if
! is_int( $key )
. - This runs on the result of
trim( $output )
, which returns a string. $value
is already cast tostring
.
- This only runs if
- The getID3 library is an external library. If changes are not specific to WordPress Core or particularly urgent, ideally they should be made on the getID3 repository so all of its users benefit. If you see any issues in the current code there and open an issue, please drop it in here so others can find it. 🙂
Replacing all instance of ctype_digit with is_numeric
Trac ticket: https://core.trac.wordpress.org/ticket/58878