[buddypress-trac] [BuddyPress Trac] #9125: ctype_digit(): Argument of type int will be interpreted as string in the future
buddypress-trac
noreply at wordpress.org
Sat May 4 01:23:12 UTC 2024
#9125: ctype_digit(): Argument of type int will be interpreted as string in the
future
-------------------------+--------------------------
Reporter: shawfactor | Owner: espellcaste
Type: enhancement | Status: closed
Priority: low | Milestone: 14.0.0
Component: Core | Version: 12.3.0
Severity: trivial | Resolution: fixed
Keywords: has-patch |
-------------------------+--------------------------
Comment (by pashavlasovskh4):
In a recent project update, it was noted that the `ctype_digit()` function
will interpret integer arguments as strings in future PHP versions. Given
this change, what modifications should be made to ensure compatibility
across current and future PHP versions, specifically concerning function
usage in a WordPress plugin environment?
While working on the BuddyPress plugin, a warning was generated by the
`ctype_digit()` function in `bp-core/classes/class-bp-media-extractor.php`
at line 784. The context involves handling numeric values retrieved via a
REST API endpoint (`wp-json/wp/v2/posts/77494?_locale=user`). Previously,
there was an assumption that values being checked were always strings, but
some of these values are integers.
In the patch submitted, the solution involved casting integers to strings
before passing them to `ctype_digit()`. Is this approach the best practice
for maintaining functionality and forward compatibility? What other
methods could be considered, and what are the potential impacts on plugin
performance and reliability?
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9125#comment:4>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list