Make WordPress Core

Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#58878 closed defect (bug) (invalid)

Replace all instances of ctype_digit() with is_numeric()

Reported by: rajinsharwar's profile rajinsharwar Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: Cc:


As per [PHP 8.1 Deprecations](, 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)

58878.diff (2.5 KB) - added by rajinsharwar 4 months ago.

Download all attachments as: .zip

Change History (7)

This ticket was mentioned in PR #4889 on WordPress/wordpress-develop by @rajinsharwar.

4 months ago

  • Keywords has-patch added

Replacing all instance of ctype_digit with is_numeric

Trac ticket:

4 months ago

#2 @ayeshrajans
4 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).

#3 @audrasjb
4 months ago

  • Milestone changed from Awaiting Review to 6.4

#4 @audrasjb
4 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

#5 @costdev
4 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() and is_numeric() have different behaviour.
  • None of the patched uses of ctype_digit() in 58878.diff are susceptible to the deprecation notice.
    1. This only runs if ! is_int( $key ).
    2. This runs on the result of trim( $output ), which returns a string.
    3. $value is already cast to string.
  • 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. 🙂

#6 @costdev
4 months ago

  • Milestone 6.4 deleted

Woops, removing the milestone 😅

Note: See TracTickets for help on using tickets.